Systems of Equations

Cramer's Rule: Formula, Steps and Worked Examples

Cramer’s rule solves ax+by=eax+by=e and cx+dy=fcx+dy=f with x=DxDx=\frac{D_x}{D} and y=DyDy=\frac{D_y}{D}, where D=ad−bcD=ad-bc is the determinant of the coefficients and DxD_x, DyD_y are the same determinant with one column replaced by the constants. It works only when D≠0D\neq 0.

x=DxD,y=DyD,D≠0x=\frac{D_x}{D},\quad y=\frac{D_y}{D},\quad D\neq 0

Try it with your numbers

Show every step

Each variable is one determinant divided by one shared determinant, so the rule replaces the juggling of substitution with a fixed pattern of arithmetic. Below: the 2×2 and 3×3 versions, negatives and fractions, where the formula comes from, and what a zero determinant tells you.

Cramer’s rule formula for a 2×2 system

Start with the system in standard form, variables lined up and constants on the right:

ax+by=e,cx+dy=fax+by=e,\qquad cx+dy=f

Three determinants do all the work. If the 2×22\times 2 determinant is new to you, the determinant of a 2×2 matrix page covers the cross-multiplication pattern.

D=∣abcd∣=ad−bc,Dx=∣ebfd∣=ed−bf,Dy=∣aecf∣=af−ecD=\begin{vmatrix}a&b\\c&d\end{vmatrix}=ad-bc,\quad D_x=\begin{vmatrix}e&b\\f&d\end{vmatrix}=ed-bf,\quad D_y=\begin{vmatrix}a&e\\c&f\end{vmatrix}=af-ec

Then x=DxDx=\frac{D_x}{D} and y=DyDy=\frac{D_y}{D}. The procedure in four steps:

  1. Rewrite both equations as ax+by=eax+by=e with variables aligned.
  2. Compute DD. If it is 00, stop: the rule cannot continue.
  3. Build DxD_x by replacing the xx column with the constants, and DyD_y by replacing the yy column.
  4. Divide: x=DxDx=\frac{D_x}{D}, y=DyDy=\frac{D_y}{D}.
Keep the column order

The constants go into the column in the same top-to-bottom order as the equations. Writing ∣fdeb∣\begin{vmatrix}f&d\\e&b\end{vmatrix} instead of ∣ebfd∣\begin{vmatrix}e&b\\f&d\end{vmatrix} flips the sign and gives the negative of the right answer.

Note that DD uses only the coefficients, never the constants. The constants enter only through DxD_x and DyD_y, which is why one wrong sign in DD ruins both answers while a slip in DxD_x ruins just one.

Quick check

For 4x+3y=104x+3y=10 and 2x−5y=12x-5y=1, find DxD_x.

How to use Cramer’s rule with negatives and fractions

Negative numbers are where most points disappear, and the cure is mechanical: write every product in parentheses before you subtract. Solve −2x+5y=11-2x+5y=11 and 4x−3y=−14x-3y=-1.

D=∣−254−3∣=(−2)(−3)−(5)(4)=6−20=−14D=\begin{vmatrix}-2&5\\4&-3\end{vmatrix}=(-2)(-3)-(5)(4)=6-20=-14

Dx=∣115−1−3∣=(11)(−3)−(5)(−1)=−33+5=−28D_x=\begin{vmatrix}11&5\\-1&-3\end{vmatrix}=(11)(-3)-(5)(-1)=-33+5=-28

Dy=∣−2114−1∣=(−2)(−1)−(11)(4)=2−44=−42D_y=\begin{vmatrix}-2&11\\4&-1\end{vmatrix}=(-2)(-1)-(11)(4)=2-44=-42

So x=−28−14=2x=\frac{-28}{-14}=2 and y=−42−14=3y=\frac{-42}{-14}=3. A negative DD is perfectly normal. The sign cancels when DxD_x and DyD_y are negative too, and an answer that looks “too clean” is usually a sign you did it right.

For fractions, clear the denominators first rather than carrying fractions through three determinants. Take x2+y3=4\frac{x}{2}+\frac{y}{3}=4 and x−y=3x-y=3. Multiplying the first equation by the common denominator 66 gives 3x+2y=243x+2y=24. Now D=(3)(−1)−(2)(1)=−5D=(3)(-1)-(2)(1)=-5, Dx=(24)(−1)−(2)(3)=−30D_x=(24)(-1)-(2)(3)=-30 and Dy=(3)(3)−(24)(1)=−15D_y=(3)(3)-(24)(1)=-15. That gives x=6x=6 and y=3y=3. Decimals work the same way: multiply by 1010 or 100100 until every coefficient is an integer.

Why does the formula work? One idea about area

Two parallelograms showing the area 3 doubling to 6 when the constants column replaces a column
With b = 2a₁ + a₂, replacing a₁ by b makes the parallelogram twice as big, so Dₓ = 2D.

The formula is not a trick to memorise. Read the system as a statement about columns: the constants column is xx copies of the first coefficient column plus yy copies of the second. Call those columns a1\mathbf{a}_1, a2\mathbf{a}_2 and b\mathbf{b}, so b=xa1+ya2\mathbf{b}=x\mathbf{a}_1+y\mathbf{a}_2. A 2×22\times 2 determinant is the signed area of the parallelogram built on its two columns.

Now replace the first column with b\mathbf{b}. The extra ya2y\mathbf{a}_2 piece lies along the other side of the parallelogram, so it adds no area, and only the stretch xa1x\mathbf{a}_1 counts:

Dx=∣ba2∣=∣xa1+ya2a2∣=x∣a1a2∣=xDD_x=\begin{vmatrix}\mathbf{b}&\mathbf{a}_2\end{vmatrix}=\begin{vmatrix}x\mathbf{a}_1+y\mathbf{a}_2&\mathbf{a}_2\end{vmatrix}=x\begin{vmatrix}\mathbf{a}_1&\mathbf{a}_2\end{vmatrix}=xD

Divide by DD and the rule appears. The same idea gives Dy=yDD_y=yD, and it extends to 3×3 systems with volumes instead of areas.

The algebraic route is plain elimination done once, in general. Multiply the first equation by dd and the second by bb, then subtract:

d(ax+by)−b(cx+dy)=de−bf(ad−bc) x=ed−bf\begin{aligned}d(ax+by)-b(cx+dy)&=de-bf\\(ad-bc)\,x&=ed-bf\end{aligned}

That line is Dx=DxDx=D_x in disguise. It also shows why D=0D=0 is fatal: you would be dividing both sides by zero. Geometrically, a zero area means the two columns point along one line, so they cannot combine to reach an arbitrary constants column.

How do you solve a 3×3 system with Cramer’s rule?

The pattern is identical, with one more determinant. Replace the column of the variable you want with the constants, keep the rest, and divide by DD. Solve:

x+y+z=6,2x−y+z=3,x+2y−z=2x+y+z=6,\qquad 2x-y+z=3,\qquad x+2y-z=2

Expand each determinant along the first row (the determinant of a 3×3 matrix page shows the cofactor signs +,−,++,-,+).

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

Dx=∣6113−1122−1∣=6(−1)−1(−5)+1(8)=7D_x=\begin{vmatrix}6&1&1\\3&-1&1\\2&2&-1\end{vmatrix}=6(-1)-1(-5)+1(8)=7

Dy=∣16123112−1∣=1(−5)−6(−3)+1(1)=14D_y=\begin{vmatrix}1&6&1\\2&3&1\\1&2&-1\end{vmatrix}=1(-5)-6(-3)+1(1)=14

Dz=∣1162−13122∣=1(−8)−1(1)+6(5)=21D_z=\begin{vmatrix}1&1&6\\2&-1&3\\1&2&2\end{vmatrix}=1(-8)-1(1)+6(5)=21

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

Missing variable means zero

If an equation lacks a variable, such as x+2z=5x+2z=5, write it as x+0y+2z=5x+0y+2z=5 before building any determinant. Skipping the zero shifts every later column and wrecks the result.

A faster finish: once xx and yy are known, substitute into any original equation to get zz. Here 1+2+z=61+2+z=6 gives z=3z=3, and the fourth determinant is never needed. That saves roughly a quarter of the work. If you want to compare, the elimination approach for three equations reaches the same point (1,2,3)(1,2,3).

Quick check

Find DD for x+2y=5x+2y=5, y+z=3y+z=3, x+z=2x+z=2. (Write the missing variables as 00 first.)

What happens when the determinant is zero?

Two coordinate grids comparing parallel lines with no solution and identical lines with infinitely many solutions
Both systems have D = 0, but Dₓ = −8 gives parallel lines while Dₓ = 0 gives one shared line.

When D=0D=0, the fractions DxD\frac{D_x}{D} and DyD\frac{D_y}{D} are undefined, so the rule is silent about the solution. The system has either no solution or infinitely many, and the numerator determinants tell them apart in the 2×2 case:

  • D=0D=0 and at least one of DxD_x, DyD_y nonzero: no solution.
  • D=0D=0 and both Dx=Dy=0D_x=D_y=0: infinitely many solutions.

Try 2x+4y=62x+4y=6 and x+2y=5x+2y=5. Here D=(2)(2)−(4)(1)=0D=(2)(2)-(4)(1)=0 and Dx=(6)(2)−(4)(5)=−8≠0D_x=(6)(2)-(4)(5)=-8\neq 0, so there is no solution. Change the first equation to 2x+4y=102x+4y=10 and every determinant becomes 00, because both equations now describe the same line. The deeper comparison lives on the no solution vs infinitely many solutions page.

The graph explains it. D=ad−bc=0D=ad-bc=0 means ab=cd\frac{a}{b}=\frac{c}{d}, so both lines have the same slope. In slope-intercept form that is two lines with equal mm: parallel (no solution) or identical (infinitely many), as solving systems by graphing shows visually.

One caution for larger systems: in 3×3, all four determinants being zero does not guarantee infinitely many solutions. The system x+y+z=1x+y+z=1, x+y+z=2x+y+z=2, x+y+z=3x+y+z=3 has every determinant equal to 00 and still has no solution. In that case, switch to row reduction or elimination.

Try this: Take 3x+6y=123x+6y=12 and x+2y=kx+2y=k. Compute DD, then find the single value of kk that makes Dx=0D_x=0. What does that value mean for the lines?

Cramer’s rule vs elimination: which is faster?

For a 2×2 system the methods are close, and Cramer’s rule wins when the numbers are awkward, because it never forces you to divide mid-calculation. It also wins when only one variable is wanted: x=DxDx=\frac{D_x}{D} needs two determinants, not a full solve.

Method Best when Weak spot
Cramer’s rule 2×2 or 3×3, one variable needed, letters as coefficients Many determinants as size grows
Elimination Any size, coefficients that line up Easy to slip on signs mid-way
Substitution One variable already isolated Fractions pile up fast

The cost grows quickly. An n×nn\times n system needs n+1n+1 determinants of size nn, and each one costs more than the last, so beyond 3×3 the rule is a poor choice for hand work. To feel the difference, solve one system all three ways using the elimination method practice problems and the substitution method practice problems, then time yourself.

How to check the answer without redoing the work

Substitute into the original equations, not into the rewritten ones, so any mistake in setup is caught too. In a 3×3 system, test all three equations. If you used one equation to find zz by the shortcut, that equation will always pass, so the other two carry the real check.

Two faster mental checks exist for systems with integer coefficients. First, every answer is integerD\frac{\text{integer}}{D}, so after reducing, its denominator must divide ∣D∣|D|. If D=−14D=-14 and you get x=34x=\frac{3}{4}, something is wrong before you substitute. Second, swapping the two equations flips the sign of DD, DxD_x and DyD_y together, so the quotients stay put. Redoing the problem with the equations swapped is a cheap independent test.

When the check fails, look at the columns first. A swapped constants column, or a coefficient placed in the wrong spot, causes more wrong answers than arithmetic does.

Quick check

For x+y=5x+y=5 and x−y=1x-y=1, D=−2D=-2 and x=3x=3. If the two equations are swapped, what is the new DD, and what happens to xx?

Real uses: tickets, circuits and where lines cross

A concert sells adult tickets at $12 and student tickets at $8. In total, 5050 tickets bring in $460. With aa adults and ss students:

a+s=50,12a+8s=460a+s=50,\qquad 12a+8s=460

Here D=(1)(8)−(1)(12)=−4D=(1)(8)-(1)(12)=-4, Da=(50)(8)−(1)(460)=−60D_a=(50)(8)-(1)(460)=-60 and Ds=(1)(460)−(50)(12)=−140D_s=(1)(460)-(50)(12)=-140. So a=−60−4=15a=\frac{-60}{-4}=15 and s=−140−4=35s=\frac{-140}{-4}=35. Check: 15+35=5015+35=50 and 12(15)+8(35)=180+280=46012(15)+8(35)=180+280=460.

Two lines in standard form meet at a point that Cramer’s rule gives in one pass. If the lines come as point-slope form, rewrite them as Ax+By=CAx+By=C first. Engineers use the same pattern for mesh currents in circuits (Kirchhoff’s laws produce a small linear system), and it also appears in economics, where the coefficients are prices and quantities.

The rule is also the inverse-matrix formula, one component at a time. If Ax=bA\mathbf{x}=\mathbf{b} and D≠0D\neq 0, then x=A−1b\mathbf{x}=A^{-1}\mathbf{b}, and each entry of that product equals DiD\frac{D_i}{D}. The condition D≠0D\neq 0 is exactly the condition for AA to have an inverse.

Practice problems

0 of 5 solved

  1. Solve 2x+y=82x+y=8 and x−y=1x-y=1 with Cramer's rule.

  2. Solve 3x−4y=103x-4y=10 and −2x+5y=−9-2x+5y=-9.

  3. Solve x3+y2=3\frac{x}{3}+\frac{y}{2}=3 and x2−y4=12\frac{x}{2}-\frac{y}{4}=\frac{1}{2}.

  4. Solve x+y=3x+y=3, y+z=4y+z=4, x+z=5x+z=5.

  5. For which values of kk does 2x+ky=52x+ky=5, kx+8y=3kx+8y=3 fail to have exactly one solution?

Common questions

What is Cramer's rule used for?

Cramer's rule solves a system of linear equations with as many equations as unknowns by writing each unknown as a ratio of two determinants. It is most useful for 2×2 and 3×3 systems, for finding a single variable without solving the rest, and for formulas where the coefficients are letters.

What does it mean if the determinant D is zero?

The system does not have exactly one solution, so Cramer's rule cannot give an answer. In a 2×2 system, a nonzero DxD_x or DyD_y means no solution (parallel lines), and both being zero means infinitely many solutions (the same line).

How do you solve a 3×3 system with Cramer's rule?

Write the system in standard form, compute DD from the coefficients, then compute DxD_x, DyD_y and DzD_z by replacing one column at a time with the constants. Divide each by DD. After finding two variables you can substitute into an original equation for the third.

Is Cramer's rule faster than elimination?

For a 2×2 system it is about equal, and it is quicker when you need only one variable. For 3×3 it needs four 3×3 determinants, so elimination is usually shorter. For 4×4 and larger, row reduction is far more efficient.

Why is it called Cramer's rule?

It is named after the Swiss mathematician Gabriel Cramer, who published the general rule in 1750. Special cases were known earlier, but his notation and presentation made the method widely used.

Can Cramer's rule be used on a 4×4 system?

Yes, as long as D≠0D\neq 0, but it requires five 4×4 determinants, which is a lot of arithmetic by hand. Computers and textbooks use row reduction for systems that large.

Up next