Cramer's Rule - Formula, 2x2 & 3x3 Examples

#Algebra
TL;DR
Cramer's rule solves a system of linear equations by writing each unknown as a ratio of two determinants. For a system with coefficient determinant DD, the value of each variable is its own determinant divided by DD, where each numerator swaps one column of the coefficient matrix for the constants. This article gives the 2x2 and 3x3 formulas, derives where they come from, works six examples, and pins down the one condition (D≠0D \neq 0) that decides whether the method works at all.
MV
Madhukar VLast updated on June 29, 202612 min read

What Is Cramer's Rule?

Cramer's rule is a formula that solves a system of nn linear equations in nn unknowns using determinants, provided the system has exactly one solution. Each unknown equals a fraction: the denominator is the determinant of the coefficient matrix, and the numerator is that same determinant with the unknown's column replaced by the column of constants.

Two terms before we go further. A coefficient matrix is the grid of numbers multiplying the variables. A determinant is a single number computed from a square matrix; for a 2x2 matrix it is ad−bcad - bc. If either of those is new, read the determinant of a matrix explainer first, then come back here.

How Do You Use Cramer's Rule On A 2x2 System?

Start with the smallest case. Take the system

a1x+b1y=c1a_1 x + b_1 y = c_1 a2x+b2y=c2a_2 x + b_2 y = c_2

The coefficient determinant is

D=∣a1b1 a2b2∣=a1b2−a2b1D = \begin{vmatrix} a_1 & b_1 \ a_2 & b_2 \end{vmatrix} = a_1 b_2 - a_2 b_1

Now build two more determinants by swapping a column for the constants (c1,c2)(c_1, c_2):

Dx=∣c1b1 c2b2∣,Dy=∣a1c1 a2c2∣D_x = \begin{vmatrix} c_1 & b_1 \ c_2 & b_2 \end{vmatrix}, \qquad D_y = \begin{vmatrix} a_1 & c_1 \ a_2 & c_2 \end{vmatrix}

The solution is

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

Variable glossary: a1,b1,a2,b2a_1, b_1, a_2, b_2 are the coefficients; c1,c2c_1, c_2 are the constants on the right; DD is the coefficient determinant; DxD_x and DyD_y are the numerator determinants for xx and yy.

Where Does The Rule Come From?

The formula is not magic, and seeing the derivation once means you never have to memorise it. Take the 2x2 system and eliminate yy the ordinary way.

Multiply the first equation by b2b_2 and the second by b1b_1:

a1b2x+b1b2y=c1b2a_1 b_2 x + b_1 b_2 y = c_1 b_2 a2b1x+b1b2y=c2b1a_2 b_1 x + b_1 b_2 y = c_2 b_1

Subtract the second from the first. The yy terms cancel:

(a1b2−a2b1)x=c1b2−c2b1(a_1 b_2 - a_2 b_1) x = c_1 b_2 - c_2 b_1

Divide both sides by (a1b2−a2b1)(a_1 b_2 - a_2 b_1):

x=c1b2−c2b1a1b2−a2b1x = \frac{c_1 b_2 - c_2 b_1}{a_1 b_2 - a_2 b_1}

Look at the two pieces. The denominator is exactly DD, and the numerator is exactly DxD_x. The rule is just elimination, written in determinant shorthand. That is also the first hint about when it breaks: you divided by (a1b2−a2b1)(a_1 b_2 - a_2 b_1), so the whole thing collapses the moment that quantity is zero.

Steps To Solve A System With Cramer's Rule

The same five steps work for a 2x2 or a 3x3 system. The order matters, because step 2 is the one that can stop the whole process early.

  1. Write the system in standard form, lining up the coefficients so each variable sits in its own column (insert a 00 coefficient for any missing variable).

  2. Compute the coefficient determinant DD first. If D=0D = 0, stop here, the rule does not apply, and you switch to elimination or substitution.

  3. Build each numerator determinant by replacing only that variable's column with the column of constants, one variable at a time (DxD_x, DyD_y, and DzD_z for a 3x3).

  4. Divide each numerator by DD to get the variable: x=DxDx = \dfrac{D_x}{D}, y=DyDy = \dfrac{D_y}{D}, z=DzDz = \dfrac{D_z}{D}.

  5. Substitute the values back into the original equations to check that both (or all three) hold.

Examples of Cramer's Rule

Example 1

Solve 2x−y=52x - y = 5 and x+y=4x + y = 4.

Coefficient determinant:

D=∣2−1 11∣=(2)(1)−(1)(−1)=3D = \begin{vmatrix} 2 & -1 \ 1 & 1 \end{vmatrix} = (2)(1) - (1)(-1) = 3

Replace the xx-column with the constants:

Dx=∣5−1 41∣=(5)(1)−(4)(−1)=9D_x = \begin{vmatrix} 5 & -1 \ 4 & 1 \end{vmatrix} = (5)(1) - (4)(-1) = 9

Replace the yy-column with the constants:

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

Divide:

x=93=3,y=33=1x = \frac{9}{3} = 3, \qquad y = \frac{3}{3} = 1

Final answer: x=3x = 3, y=1y = 1. Substituting back, 2(3)−1=52(3) - 1 = 5 and 3+1=43 + 1 = 4. Both hold.

Example 2

Solve 3x+2y=73x + 2y = 7 and 6x+4y=16x + 4y = 1.

The first instinct is to grind through DxD_x and DyD_y right away. Try it. Watch where it goes.

Dx=∣72 14∣=28−2=26D_x = \begin{vmatrix} 7 & 2 \ 1 & 4 \end{vmatrix} = 28 - 2 = 26

So far so good. Now the denominator:

D=∣32 64∣=12−12=0D = \begin{vmatrix} 3 & 2 \ 6 & 4 \end{vmatrix} = 12 - 12 = 0

And there it is. x=260x = \frac{26}{0} is undefined. The mistake was diving into the numerators before checking DD. Always compute DD first. If D=0D = 0, Cramer's rule cannot produce a value, and you stop and switch methods. (Here the two equations describe parallel lines, 3x+2y=73x + 2y = 7 versus 3x+2y=0.53x + 2y = 0.5, so the system has no solution at all.)

Example 3

Solve 4x+3y=184x + 3y = 18 and x−2y=−1x - 2y = -1.

D=∣43 1−2∣=−8−3=−11D = \begin{vmatrix} 4 & 3 \ 1 & -2 \end{vmatrix} = -8 - 3 = -11

Dx=∣183 −1−2∣=−36−(−3)=−33D_x = \begin{vmatrix} 18 & 3 \ -1 & -2 \end{vmatrix} = -36 - (-3) = -33

Dy=∣418 1−1∣=−4−18=−22D_y = \begin{vmatrix} 4 & 18 \ 1 & -1 \end{vmatrix} = -4 - 18 = -22

x=−33−11=3,y=−22−11=2x = \frac{-33}{-11} = 3, \qquad y = \frac{-22}{-11} = 2

Final answer: x=3x = 3, y=2y = 2.

Example 4

Solve the 3x3 system x+y+z=6x + y + z = 6, ;y+3z=11;y + 3z = 11, ;x−2y+z=0;x - 2y + z = 0.

For a 3x3, DD is the determinant of the full coefficient matrix. With the missing xx in the second equation written as 0x0x:

D=∣111 013 1−21∣=1(1+6)−1(0−3)+1(0−1)=7+3−1=9D = \begin{vmatrix} 1 & 1 & 1 \ 0 & 1 & 3 \ 1 & -2 & 1 \end{vmatrix} = 1(1 + 6) - 1(0 - 3) + 1(0 - 1) = 7 + 3 - 1 = 9

Swap the first column for the constants (6,11,0)(6, 11, 0):

Dx=∣611 1113 0−21∣=6(1+6)−1(11−0)+1(−22−0)=42−11−22=9D_x = \begin{vmatrix} 6 & 1 & 1 \ 11 & 1 & 3 \ 0 & -2 & 1 \end{vmatrix} = 6(1 + 6) - 1(11 - 0) + 1(-22 - 0) = 42 - 11 - 22 = 9

Swap the second column:

Dy=∣161 0113 101∣=1(11−0)−6(0−3)+1(0−11)=11+18−11=18D_y = \begin{vmatrix} 1 & 6 & 1 \ 0 & 11 & 3 \ 1 & 0 & 1 \end{vmatrix} = 1(11 - 0) - 6(0 - 3) + 1(0 - 11) = 11 + 18 - 11 = 18

Swap the third column:

Dz=∣116 0111 1−20∣=1(0+22)−1(0−11)+6(0−1)=22+11−6=27D_z = \begin{vmatrix} 1 & 1 & 6 \ 0 & 1 & 11 \ 1 & -2 & 0 \end{vmatrix} = 1(0 + 22) - 1(0 - 11) + 6(0 - 1) = 22 + 11 - 6 = 27

Divide:

x=99=1,y=189=2,z=279=3x = \frac{9}{9} = 1, \qquad y = \frac{18}{9} = 2, \qquad z = \frac{27}{9} = 3

Final answer: x=1x = 1, y=2y = 2, z=3z = 3.

Example 5

Use Cramer's rule to find only yy in 5x+2y=165x + 2y = 16 and 3x−y=53x - y = 5.

This is where the rule earns its keep. You do not have to solve the whole system; you can read off a single variable.

D=∣52 3−1∣=−5−6=−11D = \begin{vmatrix} 5 & 2 \ 3 & -1 \end{vmatrix} = -5 - 6 = -11

Dy=∣516 35∣=25−48=−23D_y = \begin{vmatrix} 5 & 16 \ 3 & 5 \end{vmatrix} = 25 - 48 = -23

y=−23−11=2311y = \frac{-23}{-11} = \frac{23}{11}

Final answer: y=2311y = \frac{23}{11}. No need to touch xx unless you want it.

Example 6

A small word problem. Two notebooks and three pens cost 13;fournotebooksandonepencost13; four notebooks and one pen cost 16. Find the price of each.

Let xx be the notebook price and yy the pen price:

2x+3y=132x + 3y = 13 4x+y=164x + y = 16

D=∣23 41∣=2−12=−10D = \begin{vmatrix} 2 & 3 \ 4 & 1 \end{vmatrix} = 2 - 12 = -10

Dx=∣133 161∣=13−48=−35D_x = \begin{vmatrix} 13 & 3 \ 16 & 1 \end{vmatrix} = 13 - 48 = -35

Dy=∣213 416∣=32−52=−20D_y = \begin{vmatrix} 2 & 13 \ 4 & 16 \end{vmatrix} = 32 - 52 = -20

x=−35−10=3.5,y=−20−10=2x = \frac{-35}{-10} = 3.5, \qquad y = \frac{-20}{-10} = 2

Final answer: a notebook costs 3.50andapencosts3.50 and a pen costs 2. A common error here is mixing up which variable each column belongs to, or forgetting that the constants form their own column. Label your columns before you compute anything.

Why The Determinant Decides Everything

"If D=0D = 0, the rule has nothing to divide by."

That single fact carries the whole story of when a linear system has one answer, no answer, or infinitely many.

  • D≠0D \neq 0: the system has exactly one solution, and Cramer's rule delivers it.

  • D=0D = 0 and at least one numerator is also 00: the equations overlap, and the system has infinitely many solutions.

  • D=0D = 0 but the numerators are not all 00: the equations contradict each other, and the system has no solution.

Geometrically, D=0D = 0 means the lines (in 2D) or planes (in 3D) are parallel or coincident rather than crossing at a single point. The determinant is measuring whether the rows of the coefficient matrix point in genuinely independent directions. When they do not, there is no unique crossing point to find, and no formula could produce one. This is the same independence idea you meet later with the inverse of a matrix and matrix rank.

There is also a practical limit worth naming honestly. Cramer's rule is elegant for 2x2 and 3x3 systems, but for large systems it is one of the slowest methods known, because the number of determinant computations explodes. Working scientists solving a system of equations with hundreds of variables reach for Gaussian elimination, not Cramer's rule. The rule is a teaching tool and a hand-calculation shortcut, not a heavy-duty solver.

Tripping Points To Avoid

Mistake 1: Computing the numerators before checking D

Where it slips in: The very first step, when a student is eager to get to the answer.

Don't do this: Calculate DxD_x and DyD_y, then discover D=0D = 0 and realise the work was wasted, or worse, write down a number divided by zero as if it were a real answer.

The correct way: Compute DD first, every time. If D=0D = 0, stop and switch to elimination or substitution. The habit of checking DD first is the single thing that separates a clean Cramer's-rule solution from a confused one, because the rule's only failure mode lives entirely in that one number.

Mistake 2: Replacing the wrong column

Where it slips in: 3x3 systems, where there are three columns and it is easy to lose track.

Don't do this: For DyD_y, swap the constants into the first column instead of the second.

The correct way: The numerator for a variable replaces that variable's column with the constants and leaves the others alone. For DyD_y, the second column becomes the constants; columns one and three stay as the original coefficients. The memorizer who has the formula but not the picture is exactly the student who slips here, so picture which variable owns which column before you write anything down.

Mistake 3: Sign errors in the determinant expansion

Where it slips in: Expanding a 3x3 determinant along the first row.

Don't do this: Write a11M11+a12M12+a13M13a_{11}M_{11} + a_{12}M_{12} + a_{13}M_{13} with all plus signs.

The correct way: The signs alternate: +,−,++, -, + across the first row. The middle term is subtracted. A dropped minus sign here is the most common reason a Cramer's-rule answer comes out wrong even when the setup was right.

Practice Questions on Cramer's Rule

Work each one with DD computed first. Answers follow.

  1. Solve x+y=5x + y = 5 and 2x−y=12x - y = 1.

  2. Solve 3x−2y=43x - 2y = 4 and 6x−4y=96x - 4y = 9. State what happens.

  3. Use Cramer's rule to find only xx in 4x+y=114x + y = 11 and 2x+3y=132x + 3y = 13.

  4. Solve the 3x3 system x+y+z=6x + y + z = 6, ;2x−y+z=3;2x - y + z = 3, ;x+2y−z=2;x + 2y - z = 2.

  5. Two coffees and one tea cost 7;onecoffeeandthreeteascost7; one coffee and three teas cost 11. Set up the system and solve for the price of each with Cramer's rule.

Answers:

  1. D=−3D = -3, Dx=−6D_x = -6, Dy=−9D_y = -9, so x=2x = 2, y=3y = 3.

  2. D=0D = 0, so Cramer's rule cannot be used; the lines are parallel and the system has no solution.

  3. D=10D = 10, Dx=20D_x = 20, so x=2x = 2 (no need to compute yy).

  4. D=7D = 7, Dx=7D_x = 7, Dy=14D_y = 14, Dz=21D_z = 21, so x=1x = 1, y=2y = 2, z=3z = 3.

  5. With cc = coffee, tt = tea: 2c+t=72c + t = 7 and c+3t=11c + 3t = 11. D=5D = 5, Dc=10D_c = 10, Dt=15D_t = 15, so a coffee costs 2andateacosts2 and a tea costs 3.

Key Takeaways

  • Cramer's rule writes each unknown as a ratio of determinants, with the coefficient determinant DD in every denominator.

  • Each numerator replaces one variable's column with the column of constants.

  • Always compute DD first; if D=0D = 0, the rule cannot be used.

  • D=0D = 0 signals either no solution or infinitely many, never a unique one.

  • The method is ideal for 2x2 and 3x3 work and for isolating a single variable, but impractical for large systems.

A Practical Next Step

Now solve the system 3x+2y=123x + 2y = 12 and x−y=1x - y = 1 using the rule, computing DD before anything else. If the column-swapping for the numerators feels slippery, go back to the 2x2 formula section and rewrite DxD_x and DyD_y from scratch with the columns labelled. If you want to see the determinant machinery built from the ground up first, the matrix equation and elimination method explainers connect Cramer's rule to the larger toolkit, and the system of equations overview shows where it fits among the alternatives.

At Bhanzu, our trainers teach Cramer's rule by deriving it from elimination first, so students see the determinant as a shortcut they earned rather than a formula they were handed. Want a live trainer to walk through more linear-systems problems? Book a free demo class.

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

Can Cramer's rule be used for non-square systems?
No. Cramer's rule needs the same number of equations as unknowns, because it relies on the determinant of a square coefficient matrix. A 2-equation, 3-unknown system has no single determinant to work with.
Is Cramer's rule faster than elimination?
For a 2x2 or a single variable in a 3x3, often yes. For anything larger it is dramatically slower. Gaussian elimination scales far better, which is why software uses it instead.
What does it mean when D = 0?
It means the system does not have exactly one solution. Either the equations are redundant (infinitely many solutions) or contradictory (no solution). Cramer's rule cannot resolve either case.
Who invented Cramer's rule?
Gabriel Cramer published the general rule in 1750. Colin Maclaurin had published special cases two years earlier, so the history is shared, but the name stuck to Cramer.
✍️ Written By
Madhukar V
Madhukar V
Math Columnist & Analyst
I see mathematics as more than just numbers and formulas—it is a way of thinking, questioning, and understanding the world around us. I work at the intersection of mathematics, EdTech, technology, and AI-powered learning, I enjoy exploring how mathematical ideas can be made simple, meaningful, and relatable. Through my articles, I aim to present mathematics with curiosity and a practical perspective, helping readers see the beauty and relevance behind every concept in a Bhanzu way.
LinkedIn
Related Articles
Book a FREE Demo ClassBook Now →