Cramer’s Rule
Cramer’s rule solves a system of linear equations with determinants. For each variable, replace that variable’s column of coefficients with the column of constants, find the determinant, and divide it by the determinant of the coefficient matrix. It works only when that main determinant is not 0.
Before this lesson: Determinant of a Matrix, Systems of Equations and Systems of Equations in Three Variables
What Cramer’s rule does
A system like 3x + 2y = 16 and x - 4y = -4 has three columns of numbers: the x coefficients, the y coefficients and the constants on the right side. Cramer’s rule builds one determinant from the coefficients and one more for each variable.
The main determinant, D, uses only the coefficients. To get D_x, swap the x column for the constants. To get D_y, swap the y column for the constants. Then each variable equals its own determinant divided by D.
Why does this work? If you solve the system by elimination using letters instead of numbers, every answer ends up with the same denominator, ad - bc. That denominator is D, and each numerator is another determinant.
Cramer’s rule formula
For the system ax + by = e and cx + dy = f:
D = \begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bcD_x = \begin{vmatrix} e & b \\ f & d \end{vmatrix} = ed - bf, \quad D_y = \begin{vmatrix} a & e \\ c & f \end{vmatrix} = af - ecx = \frac{D_x}{D}, \quad y = \frac{D_y}{D}, \quad D \ne 0For three equations in x, y and z, use 3 × 3 determinants the same way: x = \frac{D_x}{D}, y = \frac{D_y}{D} and z = \frac{D_z}{D}.
If D = 0, Cramer’s rule can’t give one answer. The system has no solution or infinitely many. For two equations, if D = 0 and D_x or D_y is not 0, there is no solution. If all three are 0, check the equations: when one is a multiple of the other, there are infinitely many solutions.
How to use Cramer’s rule
- Write each equation in standard form, ax + by = c, with the variables lined up in the same order.
- Find D from the coefficients. If D = 0, stop and check the system another way.
- Replace the x column with the constants and find D_x. Do the same for each other variable.
- Divide: x = \frac{D_x}{D}, y = \frac{D_y}{D}, and so on.
- Check the answer in every original equation.
Cramer’s rule examples
Example 1: A 2 × 2 system
Use Cramer’s rule to solve 3x + 2y = 16 and x - 4y = -4.
D = \begin{vmatrix} 3 & 2 \\ 1 & -4 \end{vmatrix}Write D from the coefficients.
D = 3(-4) - 2(1)
Use ad - bc (see determinant of a matrix).
D = -12 - 2
Multiply (see multiplying integers).
D = -14
Subtract.
D_x = \begin{vmatrix} 16 & 2 \\ -4 & -4 \end{vmatrix}Replace the x column with the constants 16 and −4.
D_x = 16(-4) - 2(-4)
Use ad - bc.
D_x = -64 + 8
Multiply. Subtracting −8 is the same as adding 8.
D_x = -56
Add (see adding integers).
D_y = \begin{vmatrix} 3 & 16 \\ 1 & -4 \end{vmatrix}Replace the y column with the constants.
D_y = 3(-4) - 16(1)
Use ad - bc.
D_y = -12 - 16
Multiply.
D_y = -28
Subtract.
x = \frac{D_x}{D} = \frac{-56}{-14}Divide D_x by D.
x = 4
Simplify. A negative divided by a negative is positive.
y = \frac{D_y}{D} = \frac{-28}{-14}Divide D_y by D.
y = 2
Simplify.
3(4) + 2(2) = 12 + 4 = 16
Check the first equation.
4 - 4(2) = 4 - 8 = -4
Check the second equation.
Answer: (4, 2)
Example 2: Answers that are fractions
Solve 4x - 3y = 2 and 2x + 5y = 7.
D = \begin{vmatrix} 4 & -3 \\ 2 & 5 \end{vmatrix}Write D from the coefficients.
D = 4(5) - (-3)(2)
Use ad - bc.
D = 20 + 6
Multiply. Subtracting −6 is the same as adding 6.
D = 26
Add.
D_x = \begin{vmatrix} 2 & -3 \\ 7 & 5 \end{vmatrix}Replace the x column with the constants 2 and 7.
D_x = 2(5) - (-3)(7)
Use ad - bc.
D_x = 10 + 21
Multiply.
D_x = 31
Add.
D_y = \begin{vmatrix} 4 & 2 \\ 2 & 7 \end{vmatrix}Replace the y column with the constants.
D_y = 4(7) - 2(2)
Use ad - bc.
D_y = 28 - 4
Multiply.
D_y = 24
Subtract.
x = \frac{D_x}{D} = \frac{31}{26}Divide. 31 and 26 share no common factor, so the fraction is already simplified.
y = \frac{D_y}{D} = \frac{24}{26}Divide.
y = \frac{12}{13}Divide the top and bottom by 2 (see simplifying fractions).
4\left(\frac{31}{26}\right) - 3\left(\frac{12}{13}\right) = \frac{62}{13} - \frac{36}{13} = \frac{26}{13} = 2Check the first equation.
2\left(\frac{31}{26}\right) + 5\left(\frac{12}{13}\right) = \frac{31}{13} + \frac{60}{13} = \frac{91}{13} = 7Check the second equation.
Answer: \left(\frac{31}{26}, \frac{12}{13}\right)
Example 3: When D = 0
Solve 2x - 6y = 4 and -x + 3y = 5.
D = \begin{vmatrix} 2 & -6 \\ -1 & 3 \end{vmatrix}Write D from the coefficients.
D = 2(3) - (-6)(-1)
Use ad - bc.
D = 6 - 6
Multiply. Two negatives make a positive: (-6)(-1) = 6.
D = 0
Subtract. Cramer’s rule can’t give one answer.
D_x = \begin{vmatrix} 4 & -6 \\ 5 & 3 \end{vmatrix}Find D_x to tell the two cases apart.
D_x = 4(3) - (-6)(5)
Use ad - bc.
D_x = 12 + 30
Multiply.
D_x = 42
Add. So D = 0 but D_x \ne 0.
Since D = 0 and D_x \ne 0, the system has no solution. You can see why. Divide the first equation by 2 to get x - 3y = 2, and multiply the second by −1 to get x - 3y = -5. The same expression can’t equal both 2 and −5, so the two lines are parallel.
Example 4: A 3 × 3 system
Solve the system x + y + z = 6, 2x - y + z = 3 and x + 2y - z = 2.
D = \begin{vmatrix} 1 & 1 & 1 \\ 2 & -1 & 1 \\ 1 & 2 & -1 \end{vmatrix}Write D from the coefficients.
D = 1[(-1)(-1) - 1(2)] - 1[2(-1) - 1(1)] + 1[2(2) - (-1)(1)]
Expand along the first row with the signs +, −, +.
D = 1(1 - 2) - 1(-2 - 1) + 1(4 + 1)
Multiply inside the brackets.
D = -1 + 3 + 5
Simplify each term.
D = 7
Add.
D_x = \begin{vmatrix} 6 & 1 & 1 \\ 3 & -1 & 1 \\ 2 & 2 & -1 \end{vmatrix}Replace the x column with the constants 6, 3 and 2.
D_x = 6[(-1)(-1) - 1(2)] - 1[3(-1) - 1(2)] + 1[3(2) - (-1)(2)]
Expand along the first row.
D_x = 6(1 - 2) - 1(-3 - 2) + 1(6 + 2)
Multiply inside the brackets.
D_x = -6 + 5 + 8
Simplify each term.
D_x = 7
Add.
D_y = \begin{vmatrix} 1 & 6 & 1 \\ 2 & 3 & 1 \\ 1 & 2 & -1 \end{vmatrix}Replace the y column with the constants.
D_y = 1[3(-1) - 1(2)] - 6[2(-1) - 1(1)] + 1[2(2) - 3(1)]
Expand along the first row.
D_y = 1(-3 - 2) - 6(-2 - 1) + 1(4 - 3)
Multiply inside the brackets.
D_y = -5 + 18 + 1
Simplify each term.
D_y = 14
Add.
D_z = \begin{vmatrix} 1 & 1 & 6 \\ 2 & -1 & 3 \\ 1 & 2 & 2 \end{vmatrix}Replace the z column with the constants.
D_z = 1[(-1)(2) - 3(2)] - 1[2(2) - 3(1)] + 6[2(2) - (-1)(1)]
Expand along the first row.
D_z = 1(-2 - 6) - 1(4 - 3) + 6(4 + 1)
Multiply inside the brackets.
D_z = -8 - 1 + 30
Simplify each term.
D_z = 21
Add.
x = \frac{D_x}{D} = \frac{7}{7} = 1Divide D_x by D.
y = \frac{D_y}{D} = \frac{14}{7} = 2Divide D_y by D.
z = \frac{D_z}{D} = \frac{21}{7} = 3Divide D_z by D.
1 + 2 + 3 = 6
Check the first equation.
2(1) - 2 + 3 = 3
Check the second equation.
1 + 2(2) - 3 = 2
Check the third equation.
Answer: (1, 2, 3)
Example 5: Word problem
A coffee shop sells two roasts by the pound. An order of 3 pounds of dark roast and 2 pounds of blonde roast costs $47. An order of 1 pound of dark roast and 4 pounds of blonde roast costs $39. Find the price per pound of each roast.
Let d be the price of dark roast and b the price of blonde roast, in dollars per pound. The two orders give 3d + 2b = 47 and d + 4b = 39.
D = \begin{vmatrix} 3 & 2 \\ 1 & 4 \end{vmatrix}Write D from the coefficients.
D = 3(4) - 2(1)
Use ad - bc.
D = 12 - 2
Multiply.
D = 10
Subtract.
D_d = \begin{vmatrix} 47 & 2 \\ 39 & 4 \end{vmatrix}Replace the d column with the costs 47 and 39.
D_d = 47(4) - 2(39)
Use ad - bc.
D_d = 188 - 78
Multiply.
D_d = 110
Subtract.
D_b = \begin{vmatrix} 3 & 47 \\ 1 & 39 \end{vmatrix}Replace the b column with the costs.
D_b = 3(39) - 47(1)
Use ad - bc.
D_b = 117 - 47
Multiply.
D_b = 70
Subtract.
d = \frac{D_d}{D} = \frac{110}{10} = 11Divide D_d by D.
b = \frac{D_b}{D} = \frac{70}{10} = 7Divide D_b by D.
3(11) + 2(7) = 33 + 14 = 47
Check the first order.
11 + 4(7) = 11 + 28 = 39
Check the second order.
Answer: Dark roast costs $11 per pound and blonde roast costs $7 per pound.
Common mistakes
| Mistake | Example of the error | Fix |
|---|---|---|
| Replacing the wrong column | For D_x, putting the constants in the y column | The constants replace the column of the variable you are solving for. |
| Using D_x as the answer | Writing x = -56 in Example 1 | Divide: x = \frac{D_x}{D} = \frac{-56}{-14} = 4. |
| Sign errors in ad - bc | 4(5) - (-3)(2) = 20 - 6 | Subtracting a negative product adds: 20 + 6 = 26. |
| Equations not lined up | Reading 2y + x = 5 as if 2 were the x coefficient | Rewrite it as x + 2y = 5 before you read the coefficients. |
| Dividing by zero | Writing x = \frac{42}{0} when D = 0 | When D = 0, decide between no solution and infinitely many instead. |
| Wrong signs in a 3 × 3 expansion | Adding all three terms of the first row | Use the signs +, −, + across the first row. |
Cramer’s rule vs. other methods
Cramer’s rule is quickest for 2 × 2 systems, or when you need only one variable. For two equations, the elimination method is often just as fast.
A 3 × 3 system needs four determinants, so augmented matrices with row operations are often quicker. Inverse matrices help when you solve many systems with the same coefficients.
| Method | Best for | Main step |
|---|---|---|
| Cramer’s rule | 2 × 2 systems, or finding one variable | Divide determinants |
| Elimination or substitution | Small systems by hand | Combine or substitute equations |
| Augmented matrix | Three or more variables | Row operations |
| Inverse matrix | Many systems with the same coefficients | X = A^{-1}B |
Practice problems
Solve each system with Cramer’s rule. If D = 0, say whether there is no solution or infinitely many.
- x + y = 7 and 2x - y = 5
- 5x + 2y = 1 and 3x + y = 0
- 2x + 3y = 4 and 5x - 2y = 1
- 6x - 4y = 10 and -3x + 2y = 7
- 3x - y = 4 and -6x + 2y = -8
- 4x + y = -2 and x - 3y = 19
- Find only y: 7x + 2y = 3 and 3x + 4y = 17
- x + y + z = 2, 2x + y - z = 2 and x - y + 2z = 5
- Find only z: 2x + y - z = 3, x - y + 2z = 2 and 3x + 2y + z = 11
- A school play sells adult and student tickets. Four adult tickets and 6 student tickets cost $74. Three adult tickets and 2 student tickets cost $38. Find the price of each kind of ticket.
Show answers
1.
D = 1(-1) - 1(2)
Find D from the coefficients with ad - bc.
D = -1 - 2
Multiply.
D = -3
Subtract.
D_x = 7(-1) - 1(5)
Replace the x column with 7 and 5.
D_x = -7 - 5
Multiply.
D_x = -12
Subtract.
D_y = 1(5) - 7(2)
Replace the y column with 7 and 5.
D_y = 5 - 14
Multiply.
D_y = -9
Subtract.
x = \frac{-12}{-3} = 4Divide D_x by D.
y = \frac{-9}{-3} = 3Divide D_y by D.
Check: 4 + 3 = 7 and 2(4) - 3 = 5. Answer: (4, 3)
2.
D = 5(1) - 2(3)
Find D with ad - bc.
D = 5 - 6
Multiply.
D = -1
Subtract.
D_x = 1(1) - 2(0)
Replace the x column with 1 and 0.
D_x = 1 - 0
Multiply.
D_x = 1
Subtract.
D_y = 5(0) - 1(3)
Replace the y column with 1 and 0.
D_y = 0 - 3
Multiply.
D_y = -3
Subtract.
x = \frac{1}{-1} = -1Divide D_x by D.
y = \frac{-3}{-1} = 3Divide D_y by D.
Check: 5(-1) + 2(3) = 1 and 3(-1) + 3 = 0. Answer: (-1, 3)
3.
D = 2(-2) - 3(5)
Find D with ad - bc.
D = -4 - 15
Multiply.
D = -19
Subtract.
D_x = 4(-2) - 3(1)
Replace the x column with 4 and 1.
D_x = -8 - 3
Multiply.
D_x = -11
Subtract.
D_y = 2(1) - 4(5)
Replace the y column with 4 and 1.
D_y = 2 - 20
Multiply.
D_y = -18
Subtract.
x = \frac{-11}{-19} = \frac{11}{19}Divide D_x by D.
y = \frac{-18}{-19} = \frac{18}{19}Divide D_y by D.
Check: 2\left(\frac{11}{19}\right) + 3\left(\frac{18}{19}\right) = \frac{76}{19} = 4 and 5\left(\frac{11}{19}\right) - 2\left(\frac{18}{19}\right) = \frac{19}{19} = 1. Answer: \left(\frac{11}{19}, \frac{18}{19}\right)
4.
D = 6(2) - (-4)(-3)
Find D with ad - bc.
D = 12 - 12
Multiply.
D = 0
Subtract. Cramer’s rule can’t give one answer.
D_x = 10(2) - (-4)(7)
Replace the x column with 10 and 7.
D_x = 20 + 28
Multiply.
D_x = 48
Add. So D_x \ne 0.
Since D = 0 and D_x \ne 0, there is no solution. Dividing the first equation by −2 gives -3x + 2y = -5, which can’t also equal 7.
5.
D = 3(2) - (-1)(-6)
Find D with ad - bc.
D = 6 - 6
Multiply.
D = 0
Subtract.
D_x = 4(2) - (-1)(-8)
Replace the x column with 4 and −8.
D_x = 8 - 8
Multiply.
D_x = 0
Subtract.
D_y = 3(-8) - 4(-6)
Replace the y column with 4 and −8.
D_y = -24 + 24
Multiply.
D_y = 0
Add.
All three determinants are 0, and the second equation is −2 times the first. Both equations describe the same line, so there are infinitely many solutions: every point with y = 3x - 4.
6.
D = 4(-3) - 1(1)
Find D with ad - bc.
D = -12 - 1
Multiply.
D = -13
Subtract.
D_x = (-2)(-3) - 1(19)
Replace the x column with −2 and 19.
D_x = 6 - 19
Multiply.
D_x = -13
Subtract.
D_y = 4(19) - (-2)(1)
Replace the y column with −2 and 19.
D_y = 76 + 2
Multiply.
D_y = 78
Add.
x = \frac{-13}{-13} = 1Divide D_x by D.
y = \frac{78}{-13} = -6Divide D_y by D.
Check: 4(1) + (-6) = -2 and 1 - 3(-6) = 19. Answer: (1, -6)
7.
D = 7(4) - 2(3)
Find D with ad - bc.
D = 28 - 6
Multiply.
D = 22
Subtract.
D_y = 7(17) - 3(3)
Replace the y column with 3 and 17.
D_y = 119 - 9
Multiply.
D_y = 110
Subtract.
y = \frac{D_y}{D} = \frac{110}{22} = 5Divide D_y by D.
Answer: y = 5. Check: then 7x + 10 = 3, so x = -1, and 3(-1) + 4(5) = 17.
8.
D = 1[1(2) - (-1)(-1)] - 1[2(2) - (-1)(1)] + 1[2(-1) - 1(1)]
Expand D along the first row.
D = 1(2 - 1) - 1(4 + 1) + 1(-2 - 1)
Multiply inside the brackets.
D = 1 - 5 - 3
Simplify each term.
D = -7
Add.
D_x = 2[1(2) - (-1)(-1)] - 1[2(2) - (-1)(5)] + 1[2(-1) - 1(5)]
Replace the x column with 2, 2 and 5, then expand.
D_x = 2(2 - 1) - 1(4 + 5) + 1(-2 - 5)
Multiply inside the brackets.
D_x = 2 - 9 - 7
Simplify each term.
D_x = -14
Add.
D_y = 1[2(2) - (-1)(5)] - 2[2(2) - (-1)(1)] + 1[2(5) - 2(1)]
Replace the y column with 2, 2 and 5, then expand.
D_y = 1(4 + 5) - 2(4 + 1) + 1(10 - 2)
Multiply inside the brackets.
D_y = 9 - 10 + 8
Simplify each term.
D_y = 7
Add.
D_z = 1[1(5) - 2(-1)] - 1[2(5) - 2(1)] + 2[2(-1) - 1(1)]
Replace the z column with 2, 2 and 5, then expand.
D_z = 1(5 + 2) - 1(10 - 2) + 2(-2 - 1)
Multiply inside the brackets.
D_z = 7 - 8 - 6
Simplify each term.
D_z = -7
Add.
x = \frac{-14}{-7} = 2Divide D_x by D.
y = \frac{7}{-7} = -1Divide D_y by D.
z = \frac{-7}{-7} = 1Divide D_z by D.
Check: 2 - 1 + 1 = 2, 2(2) - 1 - 1 = 2 and 2 + 1 + 2(1) = 5. Answer: (2, -1, 1)
9.
D = 2[(-1)(1) - 2(2)] - 1[1(1) - 2(3)] + (-1)[1(2) - (-1)(3)]
Expand D along the first row.
D = 2(-1 - 4) - 1(1 - 6) - 1(2 + 3)
Multiply inside the brackets.
D = -10 + 5 - 5
Simplify each term.
D = -10
Add.
D_z = 2[(-1)(11) - 2(2)] - 1[1(11) - 2(3)] + 3[1(2) - (-1)(3)]
Replace the z column with 3, 2 and 11, then expand.
D_z = 2(-11 - 4) - 1(11 - 6) + 3(2 + 3)
Multiply inside the brackets.
D_z = -30 - 5 + 15
Simplify each term.
D_z = -20
Add.
z = \frac{D_z}{D} = \frac{-20}{-10} = 2Divide D_z by D.
Answer: z = 2. (The full solution is (1, 3, 2).)
10.
D = 4(2) - 6(3)
Let a and s be the adult and student prices: 4a + 6s = 74 and 3a + 2s = 38. Find D.
D = 8 - 18
Multiply.
D = -10
Subtract.
D_a = 74(2) - 6(38)
Replace the a column with 74 and 38.
D_a = 148 - 228
Multiply.
D_a = -80
Subtract.
D_s = 4(38) - 74(3)
Replace the s column with 74 and 38.
D_s = 152 - 222
Multiply.
D_s = -70
Subtract.
a = \frac{-80}{-10} = 8Divide D_a by D.
s = \frac{-70}{-10} = 7Divide D_s by D.
Check: 4(8) + 6(7) = 32 + 42 = 74 and 3(8) + 2(7) = 24 + 14 = 38. Answer: adult tickets cost $8 and student tickets cost $7.
Cramer’s rule FAQ
When can you use Cramer’s rule?
Use it when the system has as many equations as variables and the determinant of the coefficients is not 0. Then the system has exactly one solution, and Cramer’s rule finds it.
What happens if the determinant is 0?
The system has no solution or infinitely many solutions, and Cramer’s rule alone can’t find them. Solve it another way, such as with elimination or row operations.
Is Cramer’s rule faster than elimination?
For two equations, the two methods are about equally quick. For three or more equations, Cramer’s rule needs many determinants, so row operations are usually faster, unless you need only one variable.
Does Cramer’s rule work for 4 × 4 systems?
Yes. The rule works for any square system, but each 4 × 4 determinant takes a lot of arithmetic. Larger systems are usually solved with row operations or technology.
Summary
- Cramer’s rule solves a square system with determinants: x = \frac{D_x}{D}, y = \frac{D_y}{D}, and so on.
- D uses the coefficients. To get D_x, replace the x column with the constants.
- The rule gives one answer only when D \ne 0.
- If D = 0, the system has no solution or infinitely many.
- Always check the answer in every original equation.
Previous lesson: Inverse Matrices
Next lesson: Matrix Transformations
Back to the Precalculus Index