Determinants and Cramer's Rule Advanced. This lesson goes beyond core Algebra II. You can skip it.

Learning goals

  • Find ad−bcad - bc in elimination, and use D≠0D \ne 0 to test uniqueness
  • Compute a 2×22 \times 2 determinant, and a 3×33 \times 3 determinant by cofactor expansion
  • Apply Cramer's rule to two- and three-variable systems, replacing a column with the constants
  • Choose row reduction over Cramer's rule for large systems

Solving the general two-variable system

Watch the pattern appear on real numbers before meeting the letters. Solve

4x+y=13,x−y=2.\begin{aligned} 4x + y &= 13, \\ x - y &= 2. \end{aligned}

To clear yy, multiply the first equation by −1-1 (the yy-coefficient of the second equation) and the second equation by 11 (the yy-coefficient of the first). That is the same move you are about to see done with letters:

−4x−y=−13,x−y=2.\begin{aligned} -4x - y &= -13, \\ x - y &= 2. \end{aligned}

Subtract the second line from the first. The yy terms cancel, and xx is left with the coefficient −5-5:

−5x=−15,sox=3,and theny=13−4(3)=1.-5x = -15, \qquad \text{so} \qquad x = 3, \qquad \text{and then} \qquad y = 13 - 4(3) = 1.

Where did that −5-5 come from? From the four coefficients 4,1,1,−14, 1, 1, -1, combined as 4×(−1)−1×14 \times (-1) - 1 \times 1. Hold on to that combination. It is about to reappear, unchanged, when the same two steps are repeated with letters instead of numbers.

Take the most general system of two linear equations in two unknowns. Write the coefficients as letters so the result works for every system at once:

ax+by=e,cx+dy=f.\begin{aligned} ax + by &= e, \\ cx + dy &= f. \end{aligned}

Solve it by elimination, with one thing to watch for. The multipliers about to appear, dd and bb, are letters standing for coefficients that could themselves be 00 for some particular system, unlike the nonzero multiplier the row operations of the last lesson required. That is not a problem here, because at this stage all that is needed is a one-way fact: multiply both sides of a true equation by any number, zero included, and the result is still a true equation. So whatever the actual solution turns out to be, it must satisfy the combination about to be built, whether or not dd or bb happens to be zero. Whether the reverse holds, whether the values this process produces actually solve the system, is checked separately below, and only for the case where the process can be completed, D≠0D \ne 0. To clear yy, multiply the first equation by dd and the second by bb, so the yy terms match:

adx+bdy=ed,bcx+bdy=bf.\begin{aligned} adx + bdy &= ed, \\ bcx + bdy &= bf. \end{aligned}

Subtract the second line from the first. The bdybdy terms cancel, and xx is left with the coefficient ad−bcad - bc:

(ad−bc) x=ed−bf.(ad - bc)\,x = ed - bf.

Check it against the numbers you already found: with a=4a = 4, b=1b = 1, c=1c = 1, d=−1d = -1, this coefficient is exactly the −5-5 you computed by hand above.

Now do the mirror image to clear xx. Multiply the first equation by cc and the second by aa, letting the same one-way reasoning cover cc and aa whether or not either happens to be zero, then subtract the first from the second, and the same coefficient ad−bcad - bc reappears in front of yy:

(ad−bc) y=af−ce.(ad - bc)\,y = af - ce.

Look at what these two results share. The quantity ad−bcad - bc sits in front of both xx and yy, which means it becomes the denominator the moment you divide to solve:

x=ed−bfad−bc,y=af−cead−bc.x = \frac{ed - bf}{ad - bc}, \qquad y = \frac{af - ce}{ad - bc}.

One combination of the four coefficients controls both answers. If it is not zero, you can divide and the system has a clean solution. If it is zero, the division is illegal, and that tells you the two equations no longer pin down one single point. A number that important should not stay nameless.

The determinant and its bar notation

The shared quantity ad−bcad - bc is the determinant of the four coefficients, arranged in the square grid in which they appear:

∣abcd∣=ad−bc.\begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc.

The straight bars are the determinant symbol. The rule they stand for is short: multiply down the main diagonal (aa times dd), then subtract the product up the other diagonal (bb times cc). We write the coefficient determinant of our system as DD, so D=ad−bcD = ad - bc.

The 2 by 2 diagonal ruleThe main diagonal a to d gives the product ad, the anti-diagonal b to c gives bc, and the determinant is ad minus bc.abcdmain diagonalanti-diagonalD = ad − bc
The 2 by 2 determinant is the product down the main diagonal minus the product up the anti-diagonal.

Check your understanding

Evaluate the determinant ∣2534∣\begin{vmatrix} 2 & 5 \\ 3 & 4 \end{vmatrix}.

Answer choices

Cramer’s rule for a two-variable system

Look again at the answers we derived,

x=ed−bfad−bc,y=af−cead−bc,x = \frac{ed - bf}{ad - bc}, \qquad y = \frac{af - ce}{ad - bc},

and notice that every numerator is itself a determinant. The denominator is DD in both. The numerator for xx is ed−bfed - bf, which is the determinant you get from DD by a single column replacement. You take DD and replace its first column (the xx-column, aa and cc) with the constants ee and ff. The numerator for yy is af−ceaf - ce, the determinant from replacing the second column (the yy-column, bb and dd) with the same constants. Name these column-replacement determinants DxD_x and DyD_y:

Dx=∣ebfd∣=ed−bf,Dy=∣aecf∣=af−ce.D_x = \begin{vmatrix} e & b \\ f & d \end{vmatrix} = ed - bf, \qquad D_y = \begin{vmatrix} a & e \\ c & f \end{vmatrix} = af - ce.

With that naming, the whole solution collapses into a pattern worth memorizing. This is Cramer’s rule:

x=DxD,y=DyD(D≠0).x = \frac{D_x}{D}, \qquad y = \frac{D_y}{D} \qquad (D \ne 0).
Column replacement in Cramer’s ruleD keeps all four coefficients; D sub x replaces the first column with the constants; D sub y replaces the second column with the constants.abcdDebfdDxaecfDy
Cramer's rule builds each numerator by replacing one column of D with the constant column: the x-numerator replaces the x-column, the y-numerator replaces the y-column.

Why Cramer's rule gives the exact solution when D≠0D \ne 0#

Look back at the elimination. Starting from the two original equations, honest algebra produced D x=DxD\,x = D_x and D y=DyD\,y = D_y, so every solution of the system must satisfy those two relations. When D≠0D \ne 0 we may divide, and the relations force

x=DxD,y=DyD.x = \frac{D_x}{D}, \qquad y = \frac{D_y}{D}.

No other values are possible, so the system has at most this one solution. It remains to check that this pair actually solves the system, since forcing the values does not by itself guarantee they work. Substitute them into the first equation and clear the denominator:

a⋅DxD+b⋅DyD=a(ed−bf)+b(af−ce)ad−bc=aed−bcead−bc=e(ad−bc)ad−bc=e.a\cdot\frac{D_x}{D} + b\cdot\frac{D_y}{D} = \frac{a(ed - bf) + b(af - ce)}{ad - bc} = \frac{aed - bce}{ad - bc} = \frac{e(ad - bc)}{ad - bc} = e.

The middle step used −abf+baf=0-abf + baf = 0, so those terms drop and ee factors out of what remains. The same computation on cx+dycx + dy returns ff. The pair therefore satisfies both equations, and it is the only pair that can, so it is the unique solution.

Worked example 1 Solve 3x+2y=163x + 2y = 16 and 5x−3y=145x - 3y = 14 by Cramer's rule

Read the coefficients straight off the equations. The coefficient determinant is

D=∣325−3∣=(3)(−3)−(2)(5)=−9−10=−19.D = \begin{vmatrix} 3 & 2 \\ 5 & -3 \end{vmatrix} = (3)(-3) - (2)(5) = -9 - 10 = -19.

Since D≠0D \ne 0, the system has a unique solution and Cramer’s rule applies. For DxD_x, replace the xx-column with the constants 1616 and 1414:

Dx=∣16214−3∣=(16)(−3)−(2)(14)=−48−28=−76.D_x = \begin{vmatrix} 16 & 2 \\ 14 & -3 \end{vmatrix} = (16)(-3) - (2)(14) = -48 - 28 = -76.

For DyD_y, replace the yy-column with the constants instead:

Dy=∣316514∣=(3)(14)−(16)(5)=42−80=−38.D_y = \begin{vmatrix} 3 & 16 \\ 5 & 14 \end{vmatrix} = (3)(14) - (16)(5) = 42 - 80 = -38.

Now divide:

x=DxD=−76−19=4,y=DyD=−38−19=2.x = \frac{D_x}{D} = \frac{-76}{-19} = 4, \qquad y = \frac{D_y}{D} = \frac{-38}{-19} = 2.

The solution is (x,y)=(4,2)(x, y) = (4, 2). A quick check confirms it: 3(4)+2(2)=163(4) + 2(2) = 16 and 5(4)−3(2)=145(4) - 3(2) = 14. Notice DD was negative the whole way through, which never caused trouble, because a determinant is allowed to be negative.

Check your understanding

Solve 2x+3y=72x + 3y = 7 and x−y=1x - y = 1 with Cramer's rule. What is (x,y)(x, y)?

Answer choices

The determinant test for a unique solution

The derivation quietly answered a deeper question than “what is the solution.” It told us exactly when a solution exists and is unique. Everything hinged on whether we were allowed to divide by DD, so DD answers one specific question: does this system have exactly one solution, or not?

A two-variable system has a unique solution exactly when D≠0D \ne 0#

We prove both directions, since “exactly when” is a claim in both. Throughout, recall the two relations that hold for any solution: D x=DxD\,x = D_x and D y=DyD\,y = D_y.

First, if D≠0D \ne 0, the previous proof already produced one and only one solution, x=Dx/Dx = D_x/D and y=Dy/Dy = D_y/D. So D≠0D \ne 0 gives a unique solution.

Now the other direction: suppose D=0D = 0, and show the solution cannot be unique. With D=0D = 0 the two relations read 0=Dx0 = D_x and 0=Dy0 = D_y, and both must hold for any solution to exist at all. Two cases cover it.

If either Dx≠0D_x \ne 0 or Dy≠0D_y \ne 0, then one of the relations says 0=(a nonzero number)0 = (\text{a nonzero number}), which nothing can make true. The system then has no solution.

If instead Dx=0D_x = 0 and Dy=0D_y = 0 as well, look at the two equations directly, and sort them by how many variable coefficients are zero.

Suppose both equations have every variable coefficient equal to zero, so each reads 0x+0y=(some constant)0x + 0y = (\text{some constant}). If either constant is nonzero, that one equation alone is already false, so the system has no solution. If both constants are zero, every point (x,y)(x, y) satisfies both equations, which is still infinitely many solutions, just not confined to a single line.

Suppose instead exactly one equation has every variable coefficient equal to zero, so it reads 0x+0y=(some constant)0x + 0y = (\text{some constant}) while the other equation keeps a nonzero coefficient. A nonzero constant in the degenerate equation contradicts itself, so the system has no solution. A zero constant there says nothing at all, so the solution set is exactly the line the other, nondegenerate equation describes: infinitely many solutions.

Suppose finally that neither equation is degenerate; both keep a nonzero coefficient on at least one variable. Since D=0D = 0, the coefficient rows (a,b)(a, b) and (c,d)(c, d) are proportional. Because Dx=Dy=0D_x = D_y = 0 forces the constants to scale by that same factor as well, one equation is a constant multiple of the other. The two therefore impose at most one line’s worth of constraint, so the solution set is never a single point. In the consistent case that set is a whole line, giving infinitely many solutions.

Either way, a system with D=0D = 0 has no solution or infinitely many, never exactly one. Combined with the first direction, a system has a unique solution precisely when D≠0D \ne 0.

This is the tidy end of the one-none-infinitely-many trichotomy you met at the start of the chapter. The determinant is a single number that detects which case you are in:

Be careful with that last point, because it is the easiest thing to overstate. A zero determinant does not mean “no solution.” It means “not a unique solution,” which is either no solution or infinitely many. You need one more look at the constants to decide which.

See the difference on numbers. Pair 3x+y=63x + y = 6 with 6x+2y=126x + 2y = 12: the second equation is the first one doubled, so every point on the line 3x+y=63x + y = 6 satisfies both, and every determinant is zero, D=Dx=Dy=0D = D_x = D_y = 0. That is infinitely many solutions. Now pair the same 3x+y=63x + y = 6 with 6x+2y=96x + 2y = 9 instead. The coefficients still double, 6=2(3)6 = 2(3) and 2=2(1)2 = 2(1), so D=0D = 0 again, but the constant does not match that doubling, 9≠2(6)9 \ne 2(6), so Dx=6(2)−1(9)=3D_x = 6(2) - 1(9) = 3, which is not zero. The two lines are parallel and never meet: no solution.

Check your understanding

For which values of kk does the system {kx+y=1x+ky=3\begin{cases} kx + y = 1 \\ x + ky = 3 \end{cases} have exactly one solution?

Answer choices

Determinants of three-variable systems

For three unknowns the coefficients form a 3×33 \times 3 array, and its determinant is built out of 2×22 \times 2 determinants. Expand along the first row: multiply each top entry by the 2×22 \times 2 determinant left after crossing out that entry’s own row and column. Then attach the alternating signs to those products in order: plus, minus, plus.

∣abcdefghi∣=a∣efhi∣−b∣dfgi∣+c∣degh∣.\begin{vmatrix} a & b & c \\ d & e & f \\ g & h & i \end{vmatrix} = a\begin{vmatrix} e & f \\ h & i \end{vmatrix} - b\begin{vmatrix} d & f \\ g & i \end{vmatrix} + c\begin{vmatrix} d & e \\ g & h \end{vmatrix}.

Each small determinant is the minor of the entry in front of it. The middle term carries a minus sign, which is the single most common slip, so watch for it. This method is called cofactor expansion, and it reduces any 3×33 \times 3 determinant to three easy 2×22 \times 2 ones.

Worked example 2 Evaluate a 3 by 3 determinant by cofactor expansion

Expand along the first row of

∣123014560∣.\begin{vmatrix} 1 & 2 & 3 \\ 0 & 1 & 4 \\ 5 & 6 & 0 \end{vmatrix}.

Take the three top entries 11, 22, 33 in turn, each with its minor and its sign:

1∣1460∣−2∣0450∣+3∣0156∣.1\begin{vmatrix} 1 & 4 \\ 6 & 0 \end{vmatrix} - 2\begin{vmatrix} 0 & 4 \\ 5 & 0 \end{vmatrix} + 3\begin{vmatrix} 0 & 1 \\ 5 & 6 \end{vmatrix}.

Evaluate each 2×22 \times 2 determinant:

∣1460∣=−24,∣0450∣=−20,∣0156∣=−5.\begin{vmatrix} 1 & 4 \\ 6 & 0 \end{vmatrix} = -24, \qquad \begin{vmatrix} 0 & 4 \\ 5 & 0 \end{vmatrix} = -20, \qquad \begin{vmatrix} 0 & 1 \\ 5 & 6 \end{vmatrix} = -5.

Now combine with the signs, and mind the minus on the middle term:

1(−24)−2(−20)+3(−5)=−24+40−15=1.1(-24) - 2(-20) + 3(-5) = -24 + 40 - 15 = 1.

The determinant equals 11.

Check your understanding

Evaluate ∣210321142∣\begin{vmatrix} 2 & 1 & 0 \\ 3 & 2 & 1 \\ 1 & 4 & 2 \end{vmatrix} by expanding along the first row.

Answer choices

Cramer’s rule for a three-variable system

Cramer’s rule extends to three unknowns with no new ideas, only more columns. The two-variable version came from combining the equations to make one variable’s coefficient match and cancel, then recording only what that combination implies about any solution, the same one-way reasoning as above, valid whether or not a multiplier lands on zero. Isolating one unknown among three runs through that same combining process, just applied twice instead of once, and lands on the identical pattern: each numerator swaps the constants into one column, with DD staying the shared denominator throughout. As before, this only pins down what any solution must satisfy; checking that those values actually work, when D≠0D \ne 0, is the same substitution argument as the two-variable proof, just with one more variable. Writing out that longer elimination and check in full would not teach anything the two-variable case has not already shown, so the pattern is stated here rather than rederived from scratch.

Let DD be the coefficient determinant of

a1x+b1y+c1z=d1,a2x+b2y+c2z=d2,a3x+b3y+c3z=d3.\begin{aligned} a_1 x + b_1 y + c_1 z &= d_1, \\ a_2 x + b_2 y + c_2 z &= d_2, \\ a_3 x + b_3 y + c_3 z &= d_3. \end{aligned}

Form DxD_x, DyD_y, and DzD_z by replacing the xx-, yy-, or zz-column with the constant column d1,d2,d3d_1, d_2, d_3. Then, as long as D≠0D \ne 0,

x=DxD,y=DyD,z=DzD.x = \frac{D_x}{D}, \qquad y = \frac{D_y}{D}, \qquad z = \frac{D_z}{D}.

Worked example 3 Solve a 3 by 3 system with Cramer's rule

Solve

x+y+z=6,2x−y+z=6,x+2y−z=1.\begin{aligned} x + y + z &= 6, \\ 2x - y + z &= 6, \\ x + 2y - z &= 1. \end{aligned}

Start with the coefficient determinant, expanding along the first row:

D=∣1112−1112−1∣=1(1−2)−1(−2−1)+1(4+1)=−1+3+5=7.D = \begin{vmatrix} 1 & 1 & 1 \\ 2 & -1 & 1 \\ 1 & 2 & -1 \end{vmatrix} = 1(1 - 2) - 1(-2 - 1) + 1(4 + 1) = -1 + 3 + 5 = 7.

Because D=7≠0D = 7 \ne 0, the system has a unique solution. Replace the xx-column with the constants 6,6,16, 6, 1:

Dx=∣6116−1112−1∣=6(−1)−1(−7)+1(13)=−6+7+13=14.D_x = \begin{vmatrix} 6 & 1 & 1 \\ 6 & -1 & 1 \\ 1 & 2 & -1 \end{vmatrix} = 6(-1) - 1(-7) + 1(13) = -6 + 7 + 13 = 14.

Replace the yy-column instead:

Dy=∣16126111−1∣=1(−7)−6(−3)+1(−4)=−7+18−4=7.D_y = \begin{vmatrix} 1 & 6 & 1 \\ 2 & 6 & 1 \\ 1 & 1 & -1 \end{vmatrix} = 1(-7) - 6(-3) + 1(-4) = -7 + 18 - 4 = 7.

And the zz-column:

Dz=∣1162−16121∣=1(−13)−1(−4)+6(5)=−13+4+30=21.D_z = \begin{vmatrix} 1 & 1 & 6 \\ 2 & -1 & 6 \\ 1 & 2 & 1 \end{vmatrix} = 1(-13) - 1(-4) + 6(5) = -13 + 4 + 30 = 21.

Divide each by DD:

x=147=2,y=77=1,z=217=3.x = \frac{14}{7} = 2, \qquad y = \frac{7}{7} = 1, \qquad z = \frac{21}{7} = 3.

The solution is (x,y,z)=(2,1,3)(x, y, z) = (2, 1, 3), which checks in all three equations. Had you wanted only zz, you could have computed just DD and DzD_z and skipped the other two determinants entirely.

Check your understanding

For the system 2x+y−z=32x + y - z = 3, x−y+2z=1x - y + 2z = 1, 3x+2y+z=83x + 2y + z = 8, which determinant equals DyD_y under Cramer's rule?

Answer choices

Cramer’s rule or row reduction?

Cramer’s rule and the row reduction from the previous lesson both handle a square system, the same number of equations as unknowns, so on that common ground, which should you reach for? Row reduction still reaches further: it also handles a system with more equations than unknowns or fewer, the kind Matrices and Systems solved, where Cramer’s rule does not apply at all, since there is no single coefficient determinant to divide by. Restricted to square systems, though, the two have opposite strengths, and the honest answer is that it depends on what you want.

Cramer’s rule is a closed formula: it writes each unknown as one determinant over another, with no back-substitution and no bookkeeping of row swaps. That makes it excellent in two situations. First, when you need only one unknown, you compute just DD and that variable’s numerator and stop, no matter which unknown it is. Row reduction cannot promise that: how much extra work it costs depends on where the unknown you want sits in the elimination order. Ask for the last variable eliminated and forward elimination alone hands it to you, no back-substitution needed at all; ask for an early one instead and you must first pin down every variable below it, climbing the whole staircase to reach it. Cramer’s rule pays the same one extra determinant regardless of which unknown you picked. Second, for theory, the formula shows plainly how the answer depends on the numbers in the system, which is why D≠0D \ne 0 reads off the unique-solution condition at a glance.

Row reduction wins on scale. A cofactor expansion of an n×nn \times n determinant fans out into smaller determinants and the work grows explosively with nn, and Cramer needs n+1n + 1 of these determinants. Row reduction grows far more gently, which is why it, not Cramer, is what people and computers use to solve large systems.

SituationBetter toolWhy
You need only one of the unknowns, and it could be any of themCramer’s ruleOne fixed cost, a second determinant, no matter which unknown you pick
You need only the last unknown in elimination orderEither oneForward elimination reaches it directly, with no back-substitution needed
You want a formula in the coefficientsCramer’s ruleEach unknown is a ratio of determinants
A full solve of a 2×22 \times 2 systemEither oneThe effort is about the same
A full solve of a 3×33 \times 3 systemRow reductionCramer needs four 3×33 \times 3 determinants; row reduction is usually less arithmetic
A large system (4×44 \times 4 and up)Row reductionDeterminant cost grows explosively

Check your understanding

You need the complete solution to a system with 66 equations in 66 unknowns. Which method should you use?

Answer choices

Common mistakes

Practice

Multiple Choice Questions (MCQ)

Progressively harder sets of questions. Each opens on its own page.

Core practice

Practice problems at the level of the course, to be worked out on paper. Hints one at a time, then the answer or the full worked solution, with your progress kept in this browser.

Core practice Work it out on paper 10 problems Start →
More practice (optional)

Extra sets, as hard as the Challenge set. Each one opens on its own page.

More resources (optional)

Other explanations of this lesson, if you want a second take.

A bit of history (optional)

Give a mathematician five points on a page. Which curve runs through all five of them? That question was live in the seventeen hundreds, and it is harder than it sounds. You pick a family of curves, each one carrying several unknown coefficients. Then you demand that every point satisfy the equation. Each point hands you one linear equation, and the unknowns are the coefficients themselves.

Gabriel Cramer worked on exactly this problem, in Geneva, a city that is now Swiss. He wanted curves, not arithmetic. A system was a nuisance standing in his way, and he had to clear it again and again. So what he wanted was a formula: the answer already written, waiting for numbers to be dropped in.

His book on curves appeared in 1750, and the rule you have just learned is in an appendix at the back. It says nothing whatever about how to solve a system. It says what the answer is. Every unknown is a ratio, with the same quantity underneath every time, and each numerator built by replacing one column with the constants. That shared denominator must not be zero, and it is zero in exactly the cases where no single answer exists.

That is why the rule survives in a course that also teaches row reduction. Row reduction is a procedure, and it delivers numbers. Cramer’s rule is a statement about the answer. That is what you need when the coefficients are letters, or when a single unknown out of three is all you actually want.