This site is a work in progress. New lessons are added regularly. Contact us

Determinants and Cramer's Rule

Learning goals

  • Find adbcad - bc appearing as the denominator in elimination
  • Compute a 2×22 \times 2 determinant as main minus anti-diagonal
  • Apply Cramer's rule, replacing a column with the constants
  • Expand a 3×33 \times 3 determinant by cofactors along a row
  • Tie a unique solution to D0D \ne 0
  • Choose row reduction for large systems instead

Solving the general two-variable system

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, exactly as you always have. 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 adbcad - bc:

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

Now do the mirror image to clear xx. Multiply the first equation by cc and the second by aa, then subtract the first from the second, and the same coefficient adbcad - bc reappears in front of yy:

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

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

x=edbfadbc,y=afceadbc.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 something has gone wrong with the system itself. A number that important should not stay nameless.

The determinant and its bar notation

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

abcd=adbc.\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=adbcD = 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 = adbc
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=edbfadbc,y=afceadbc,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 edbfed - bf, which is the determinant you get from DD by a single column swap. 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 afceaf - ce, the determinant from replacing the second column (the yy-column, bb and dd) with the same constants. Name these column-swapped determinants DxD_x and DyD_y:

Dx=ebfd=edbf,Dy=aecf=afce.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(D0).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 swaps the x-column, the y-numerator swaps the y-column.

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

Look back at the elimination. Starting from the two original equations, honest algebra produced Dx=DxD\,x = D_x and Dy=DyD\,y = D_y, so every solution of the system must satisfy those two relations. When D0D \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:

aDxD+bDyD=a(edbf)+b(afce)adbc=aedbceadbc=e(adbc)adbc=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 5x3y=145x - 3y = 14 by Cramer's rule

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

D=3253=(3)(3)(2)(5)=910=19.D = \begin{vmatrix} 3 & 2 \\ 5 & -3 \end{vmatrix} = (3)(-3) - (2)(5) = -9 - 10 = -19.

Since D0D \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=162143=(16)(3)(2)(14)=4828=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)=4280=38.D_y = \begin{vmatrix} 3 & 16 \\ 5 & 14 \end{vmatrix} = (3)(14) - (16)(5) = 42 - 80 = -38.

Now divide:

x=DxD=7619=4,y=DyD=3819=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.

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 is the switch that decides the whole character of the system.

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

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

First, if D0D \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 D0D \ne 0 gives a unique solution.

Now the other direction, in its contrapositive form: 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 Dx0D_x \ne 0 or Dy0D_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, assuming each has a nonzero coefficient on at least one variable. Excluding that case costs nothing, since a degenerate equation like 0x+0y=10x + 0y = 1 has no solution by itself, which is still not a unique solution. 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 D0D \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.

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=aefhibdfgi+cdegh.\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:

1146020450+30156.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+4015=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. 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 D0D \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,2xy+z=6,x+2yz=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=111211121=1(12)1(21)+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=70D = 7 \ne 0, the system has a unique solution. Replace the xx-column with the constants 6,6,16, 6, 1:

Dx=611611121=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=161261111=1(7)6(3)+1(4)=7+184=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=116216121=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.

Cramer’s rule or row reduction?

Cramer’s rule and the row reduction from the previous lesson solve the same systems, so which should you reach for? They 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, while row reduction would make you solve for everything. Second, for theory, the formula shows plainly how the answer depends on the numbers in the system, which is why D0D \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 unknownsCramer’s ruleCompute just DD and that one numerator
You want a formula in the coefficientsCramer’s ruleEach unknown is a ratio of determinants
A full solve of a 2×22 \times 2 or 3×33 \times 3Either oneThe effort is about the same
A large system (4×44 \times 4 and up)Row reductionDeterminant cost grows explosively

Common mistakes

Practice

Multiple Choice Questions (MCQ)

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

Free Response Questions (FRQ)

Longer questions in parts, to be worked out on paper. Progressive hints, the answer on its own so you can check yourself and try again, then the full worked solution, plus a rubric to mark your own work against.

Free response Work it out on paper 5 questions 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 swapping the constants into one column. 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.