On this page
Three equations, three unknowns, and a determinant chapter you have just finished. Cramer's rule joins the two: it turns the whole system into four 3×3 determinants and one division each. Below is a full worked example, then the part that is easiest to get wrong, which is what to do when D comes out as zero.
What is Cramer's rule for three variables?
Cramer's rule gives the solution of a system with as many equations as unknowns in terms of determinants, and it is valid whenever the system has a unique solution, as the Wikipedia article on Cramer's rule states. For three variables, write the system as a1x + b1y + c1z = d1, a2x + b2y + c2z = d2 and a3x + b3y + c3z = d3.
D is the determinant of the coefficients: columns a, b, c.
Dx is D with the x-column (the a's) replaced by the constants d1, d2, d3.
Dy is D with the y-column replaced by the constants.
Dz is D with the z-column replaced by the constants.
Then x = Dx/D, y = Dy/D and z = Dz/D, provided D ≠ 0.
The rule is named after Gabriel Cramer, who placed it in an appendix to his 1750 book *Introduction à l'analyse des lignes courbes algébriques*, according to his MacTutor biography. Colin Maclaurin had published special cases in 1748, as the Wikipedia article notes. The fuller story is in our post on Gabriel Cramer and the determinant rule of 1750.
How do you solve a 3×3 system with D, Dx, Dy and Dz?
Take this system:
x + y + z = 6
2x − y + z = 3
x + 2y − z = 2
Find D. Rows (1, 1, 1), (2, −1, 1), (1, 2, −1). Expanding along the first row: 1[(−1)(−1) − (1)(2)] − 1[(2)(−1) − (1)(1)] + 1[(2)(2) − (−1)(1)] = −1 + 3 + 5 = 7. D is not zero, so a unique solution exists.
Find Dx. Replace the first column with 6, 3, 2: rows (6, 1, 1), (3, −1, 1), (2, 2, −1). This gives 6(1 − 2) − 1(−3 − 2) + 1(6 + 2) = −6 + 5 + 8 = 7.
Find Dy. Replace the second column: rows (1, 6, 1), (2, 3, 1), (1, 2, −1). This gives 1(−3 − 2) − 6(−2 − 1) + 1(4 − 3) = −5 + 18 + 1 = 14.
Find Dz. Replace the third column: rows (1, 1, 6), (2, −1, 3), (1, 2, 2). This gives 1(−2 − 6) − 1(4 − 3) + 6(4 + 1) = −8 − 1 + 30 = 21.
Divide. x = 7/7 = 1, y = 14/7 = 2, z = 21/7 = 3.
Check in all three equations. 1 + 2 + 3 = 6, 2 − 2 + 3 = 3, 1 + 4 − 3 = 2. All hold.
If you prefer a diagonal method such as Sarrus' rule for each determinant, it works just as well; pick one method and use it for all four so your sign habits stay the same.
What does D = 0 mean: no solution or infinitely many?
When D = 0 you cannot divide, so Cramer's rule gives no answer by itself. What you can say depends on Dx, Dy and Dz. For 3×3 or larger systems, the Wikipedia article on Cramer's rule puts it plainly: if any of the numerator determinants is non-zero, the system is inconsistent, but all determinants being zero does not by itself mean infinitely many solutions.
D = 0 and at least one of Dx, Dy, Dz ≠ 0: no solution. Example: x + y + z = 6, x − y + z = 2, 2x + 2z = 9. Here D = 0 but Dx = 2. Adding the first two equations gives 2x + 2z = 8, which contradicts the third.
D = 0 and Dx = Dy = Dz = 0, consistent equations: infinitely many solutions. Change the last equation to 2x + 2z = 8 and all four determinants are zero. The third equation is just the sum of the first two, so y = 2 and x + z = 4, with z free.
D = 0 and Dx = Dy = Dz = 0, but still no solution: the Wikipedia example is x + y + z = 1, x + y + z = 2, x + y + z = 3. Every determinant is zero because every row of coefficients is the same, yet no x, y, z can make one expression equal 1, 2 and 3 at once.
So when everything is zero, go back to the equations: eliminate a variable, or use the matrix test in our post on consistency of linear equations by the matrix method.
When should you use Cramer's rule, and what should you check?
Cramer's rule suits three equations with small whole-number coefficients, where four determinants are quick to write. For larger systems it is slow: a system of n equations needs n + 1 determinants, while Gaussian elimination costs about the same as computing a single determinant, according to the Wikipedia article on Cramer's rule. If the numbers are messy, solving three-variable equations by elimination is often faster.
Before you move on, run this checklist:
Write every equation in the same order: x, then y, then z, then the constant on the right.
Put a 0 in any place where a variable is missing.
Compute D first. If it is zero, stop dividing and go to the D = 0 cases above.
Replace one column at a time for Dx, Dy and Dz.
Substitute your answer into all three original equations.
If you want more systems to practise on, the Fermi Problem Library has a step-by-step solver that explains the reasoning, so you can compare each determinant with your own working rather than just the final x, y and z.

![Augmented matrix [A | I] for the worked example row-reduced to [I | A inverse]](https://news.fermi.ai/media/images/2026/10/augmented-matrix-a-i-for-the-worked-example-row-reduced-to-i-88df69bc-1600x900.webp)

