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 $D$, the value of each variable is its own determinant divided by $D$, 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 \neq 0$) that decides whether the method works at all.
BT
Bhanzu TeamLast updated on June 29, 202612 min read

What Is Cramer's Rule?

Cramer's rule is a formula that solves a system of $n$ linear equations in $n$ 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 - 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

$$a_1 x + b_1 y = c_1$$ $$a_2 x + b_2 y = c_2$$

The coefficient determinant is

$$D = \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 $(c_1, c_2)$:

$$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 = \frac{D_x}{D}, \qquad y = \frac{D_y}{D}, \qquad D \neq 0$$

Variable glossary: $a_1, b_1, a_2, b_2$ are the coefficients; $c_1, c_2$ are the constants on the right; $D$ is the coefficient determinant; $D_x$ and $D_y$ are the numerator determinants for $x$ and $y$.

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 $y$ the ordinary way.

Multiply the first equation by $b_2$ and the second by $b_1$:

$$a_1 b_2 x + b_1 b_2 y = c_1 b_2$$ $$a_2 b_1 x + b_1 b_2 y = c_2 b_1$$

Subtract the second from the first. The $y$ terms cancel:

$$(a_1 b_2 - a_2 b_1) x = c_1 b_2 - c_2 b_1$$

Divide both sides by $(a_1 b_2 - a_2 b_1)$:

$$x = \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 $D$, and the numerator is exactly $D_x$. The rule is just elimination, written in determinant shorthand. That is also the first hint about when it breaks: you divided by $(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 $0$ coefficient for any missing variable).

  2. Compute the coefficient determinant $D$ first. If $D = 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 ($D_x$, $D_y$, and $D_z$ for a 3x3).

  4. Divide each numerator by $D$ to get the variable: $x = \dfrac{D_x}{D}$, $y = \dfrac{D_y}{D}$, $z = \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 = 5$ and $x + y = 4$.

Coefficient determinant:

$$D = \begin{vmatrix} 2 & -1 \ 1 & 1 \end{vmatrix} = (2)(1) - (1)(-1) = 3$$

Replace the $x$-column with the constants:

$$D_x = \begin{vmatrix} 5 & -1 \ 4 & 1 \end{vmatrix} = (5)(1) - (4)(-1) = 9$$

Replace the $y$-column with the constants:

$$D_y = \begin{vmatrix} 2 & 5 \ 1 & 4 \end{vmatrix} = (2)(4) - (1)(5) = 3$$

Divide:

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

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

Example 2

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

The first instinct is to grind through $D_x$ and $D_y$ right away. Try it. Watch where it goes.

$$D_x = \begin{vmatrix} 7 & 2 \ 1 & 4 \end{vmatrix} = 28 - 2 = 26$$

So far so good. Now the denominator:

$$D = \begin{vmatrix} 3 & 2 \ 6 & 4 \end{vmatrix} = 12 - 12 = 0$$

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

Example 3

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

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

$$D_x = \begin{vmatrix} 18 & 3 \ -1 & -2 \end{vmatrix} = -36 - (-3) = -33$$

$$D_y = \begin{vmatrix} 4 & 18 \ 1 & -1 \end{vmatrix} = -4 - 18 = -22$$

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

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

Example 4

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

For a 3x3, $D$ is the determinant of the full coefficient matrix. With the missing $x$ in the second equation written as $0x$:

$$D = \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)$:

$$D_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:

$$D_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:

$$D_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 = \frac{9}{9} = 1, \qquad y = \frac{18}{9} = 2, \qquad z = \frac{27}{9} = 3$$

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

Example 5

Use Cramer's rule to find only $y$ in $5x + 2y = 16$ and $3x - 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 = \begin{vmatrix} 5 & 2 \ 3 & -1 \end{vmatrix} = -5 - 6 = -11$$

$$D_y = \begin{vmatrix} 5 & 16 \ 3 & 5 \end{vmatrix} = 25 - 48 = -23$$

$$y = \frac{-23}{-11} = \frac{23}{11}$$

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

Example 6

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

Let $x$ be the notebook price and $y$ the pen price:

$$2x + 3y = 13$$ $$4x + y = 16$$

$$D = \begin{vmatrix} 2 & 3 \ 4 & 1 \end{vmatrix} = 2 - 12 = -10$$

$$D_x = \begin{vmatrix} 13 & 3 \ 16 & 1 \end{vmatrix} = 13 - 48 = -35$$

$$D_y = \begin{vmatrix} 2 & 13 \ 4 & 16 \end{vmatrix} = 32 - 52 = -20$$

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

Final answer: a notebook costs $3.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 = 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 \neq 0$: the system has exactly one solution, and Cramer's rule delivers it.

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

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

Geometrically, $D = 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 $D_x$ and $D_y$, then discover $D = 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 $D$ first, every time. If $D = 0$, stop and switch to elimination or substitution. The habit of checking $D$ 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 $D_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 $D_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 $a_{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 $D$ computed first. Answers follow.

  1. Solve $x + y = 5$ and $2x - y = 1$.

  2. Solve $3x - 2y = 4$ and $6x - 4y = 9$. State what happens.

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

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

  5. Two coffees and one tea cost $7; 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 = -3$, $D_x = -6$, $D_y = -9$, so $x = 2$, $y = 3$.

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

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

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

  5. With $c$ = coffee, $t$ = tea: $2c + t = 7$ and $c + 3t = 11$. $D = 5$, $D_c = 10$, $D_t = 15$, so a coffee costs $2 and a tea costs $3.

Key Takeaways

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

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

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

  • $D = 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 = 12$ and $x - y = 1$ using the rule, computing $D$ before anything else. If the column-swapping for the numerators feels slippery, go back to the 2x2 formula section and rewrite $D_x$ and $D_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
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →