Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Cramer's Rule


Each unknown as a ratio of determinants: replace one column of A by b, evaluate, divide by det A.

Preset?Cramer's rule solves a square system A x = b with a formula: each unknown x_i is the determinant of A with its i-th column replaced by b, divided by the determinant of A. It requires det A ≠ 0, which is exactly the condition for the system to have one solution. It is a closed form rather than a practical algorithm: for large systems elimination is far cheaper.
Size
n3equations and unknowns
A and b
|
|
|
A3×3
1
1
1
2
−1
1
1
2
−1
·
x3×1
x₁
x₂
x₃
=
b3×1
6
3
2
Step 1 / 6

Step explanations

1Solve A x = b by Cramer's rule (3 unknowns)
The system has 3 equations in 3 unknowns. Cramer's rule gives each unknown as a ratio of two determinants: xi = det Ai / det A, where Ai is A with its i-th column replaced by b. The first thing to check is det A itself — if it is zero the rule cannot be applied, and the system has no unique solution.
Square system, one formula per unknown - after one check. Learn more about the opening scene · what it is








Key Terms

Cramer's rule — for a square system Ax=bA\mathbf{x} = \mathbf{b} with detA0\det A \neq 0, xi=detAidetAx_i = \dfrac{\det A_i}{\det A}, where AiA_i is AA with its ii-th column replaced by b\mathbf{b}.

Coefficient matrixAA, holding the coefficients of the unknowns, one row per equation.

Right-hand sideb\mathbf{b}, the constants; shown in amber throughout the tool.

Replaced matrixAiA_i, formed by swapping b\mathbf{b} into column ii of AA.

Unique solution — exactly one x\mathbf{x}; for a square system this happens exactly when detA0\det A \neq 0.

Singular systemdetA=0\det A = 0; the system has no solution or infinitely many, and Cramer's rule does not apply.

Homogeneous systemb=0\mathbf{b} = \mathbf{0}; every detAi\det A_i is then 00, and the unique solution is x=0\mathbf{x} = \mathbf{0}.

Costn+1n + 1 determinants of size nn, which grows far faster than the cost of elimination.

Getting Started with the Visualizer

Choose a system, then watch each unknown emerge as a ratio of two determinants.

• Use the Preset pills for five systems: a 2×22 \times 2 and a 3×33 \times 3 with integer solutions, one with fractional answers, a homogeneous one, and a singular one where the rule stops
• Use the Size stepper for 22 or 33 equations; resizing keeps the existing entries and pads with the identity
• Edit any entry of AA or of b\mathbf{b} directly, or press Shuffle for a random system built to have a small integer solution
• Hover the ? icon for a reminder of the formula and its precondition
• Press play or step manually; the step log on the right lists every determinant

The first scene after the system is always detA\det A, because everything depends on it. If it is zero the run ends there with an explanation; otherwise one scene per unknown follows, and the last scene checks the solution by multiplying it back.

How the Rule Runs

The visualizer follows the formula exactly.

SystemAx=bA\mathbf{x} = \mathbf{b} with the unknowns still symbolic
DeterminantdetA\det A is evaluated; a non-zero value licenses the rest
Replace — for each ii, the matrix AiA_i is shown with b\mathbf{b} in column ii, its determinant is evaluated, and xi=detAi/detAx_i = \det A_i / \det A
Done — the solution vector fills, and AxA\mathbf{x} is recomputed to confirm it equals b\mathbf{b}

If detA=0\det A = 0 the run stops after the determinant scene. The tool does not decide between no solution and infinitely many, because Cramer's rule cannot; that question belongs to row reduction of the augmented matrix.

The Opening Scene: The System

The player opens with Ax=bA\mathbf{x} = \mathbf{b} written out: the coefficient matrix, the vector of unknowns still symbolic and greyed, and b\mathbf{b} in amber. At the default preset the system is 3×33 \times 3.

Nothing is computed yet. What the scene establishes is the shape: as many equations as unknowns, which is the only case the rule addresses.
A3×31112−1112−1·x3×1x₁x₂x₃=b3×1632
Opening scene, frozen

A x = b with the unknowns still symbolic and b in amber. As many equations as unknowns - the only shape the rule addresses, because only square matrices have determinants.

The square shape matters because the rule divides by detA\det A, and only square matrices have determinants. A system with more equations than unknowns, or fewer, needs other methods.

The colour of b\mathbf{b} is carried through the run: whenever it appears inside a replaced matrix, its column keeps the amber, so the swap is visible at a glance.

The Determinant of A

The first computation is detA\det A, evaluated by cofactor expansion and written into its slot. Everything else divides by this number.

The frozen picture below shows the default preset's detA=7\det A = 7, highlighted.
A3×31112−1112−1det A7
Determinant of A, frozen

det A = 7 evaluated and highlighted. Non-zero, so the columns are independent, the solution is unique, and every unknown is well defined.

A non-zero value here is the whole precondition of the rule and the whole content of the statement that the system has exactly one solution. It says the columns of AA are independent, so b\mathbf{b} can be written as a combination of them in exactly one way.

The tool evaluates the determinant numerically; the determinant visualizer shows the same expansion symbolically. The number that comes out is also the volume-scaling factor of AA as a transformation, which is why a zero means collapse.

Replacing a Column

For each unknown xix_i, the tool forms AiA_i by swapping b\mathbf{b} into column ii of AA, evaluates detAi\det A_i, and divides by detA\det A.

The frozen picture below is the second unknown of the default preset: A2A_2 with b\mathbf{b} in its middle column, detA2=14\det A_2 = 14, and x2=14/7=2x_2 = 14 / 7 = 2.
A₂3×316123112−1det A₂14÷det A7=x₂2
Second unknown, frozen

A2 with b swapped into its middle column, det A2 = 14, and x2 = 14 / 7 = 2. Linearity in the swapped column is why det A2 equals x2 det A.

The replaced determinant is xidetAx_i \det A, and the picture shows why. Column ii of AiA_i is b\mathbf{b}, which equals x1a1++xnanx_1 \mathbf{a}_1 + \cdots + x_n \mathbf{a}_n; a determinant is linear in each column, so detAi\det A_i splits into nn pieces, and every piece except the xiaix_i \mathbf{a}_i one has two equal columns and vanishes.

Each unknown costs a fresh n×nn \times n determinant. Nothing from detA1\det A_1 helps with detA2\det A_2, which is the reason the method scales so badly and elimination does not.

When the Determinant Is Zero

On the singular preset the columns of AA are proportional, detA=0\det A = 0, and the run stops after the determinant scene.

The frozen picture below is that stop: the system with its coefficient columns muted and no solution vector.
A2×21224·x2×1x₁x₂=b2×137
Singular system, frozen

The singular preset stopped: det A = 0, the coefficient columns muted, no solution vector. The rule cannot say whether there are no solutions or infinitely many; row reduction can.

The rule does not fail quietly here; it fails to exist, because every xix_i would be a division by zero. Geometrically the two columns lie on one line, so the combinations x1a1+x2a2x_1 \mathbf{a}_1 + x_2 \mathbf{a}_2 only ever reach that line, and b\mathbf{b} is either on it, with infinitely many ways to reach it, or off it, with none.

Which of the two holds is a question about b\mathbf{b}, not about AA, and determinants of AA cannot answer it. Row reducing the augmented matrix [Ab][A \mid \mathbf{b}] can, and that is the tool to reach for when this one stops.

The Solution

The final scene fills the solution vector next to AA and b\mathbf{b}, and the caption multiplies AxA\mathbf{x} back out to confirm it equals b\mathbf{b}.

The frozen picture below is the default preset solved: x=(1,2,3)\mathbf{x} = (1, 2, 3).
A3×31112−1112−1·x3×1123=b3×1632
Solution, frozen

x = (1, 2, 3) in place next to A and b. Four determinants for three unknowns, none sharing work - a formula, not an algorithm.

The check is not decoration. Each unknown was computed independently from its own determinant, so an arithmetic slip in one of them shows up as a mismatch in one equation, and the check catches it.

Read across the whole run and the rule's character is clear: n+1n + 1 determinants, no sharing of work between them, and a formula at the end. It is the right tool for a 2×22 \times 2 solved on paper and the right theorem for understanding why the solution is unique; for anything larger, the elimination tools in this section do the same job with a fraction of the arithmetic.

Reading the Scene Player

Each scene shows the matrices involved in one step, with the arithmetic in the caption.

• In the determinant scene, all of AA is highlighted and the detA\det A slot fills, accent if non-zero and muted if zero
• In a replace scene, AiA_i is drawn between determinant bars with the swapped column in amber and highlighted; the detAi\det A_i slot is primary, the detA\det A slot secondary, and the xix_i slot accent, with an arrow from the swapped column to its determinant
• In the done scene, the solution vector is highlighted next to AA and b\mathbf{b}
• Fractions are shown as a/ba/b in a smaller font; the unknowns not yet found are shown in grey as x1,x2,x_1, x_2, \ldots
• The step log on the right keeps a record of every determinant evaluated

Choosing a System

The five presets each make a different point.

2×22 \times 2, integers — two equations, three determinants, solution (1,3)(1, 3); the whole rule in its smallest form
3×33 \times 3, integers — four 3×33 \times 3 determinants, solution (1,2,3)(1, 2, 3); the default, and the size at which the cost of the method starts to show
2×22 \times 2, fractions — the same rule with a non-integer answer, (7/5,19/10)(7/5, 19/10); the determinants are integers, the ratios are not
Homogeneousb=0\mathbf{b} = \mathbf{0}, so every replaced matrix has a zero column and every xi=0x_i = 0
Singular — the columns of AA are proportional, detA=0\det A = 0, and the run stops with the explanation

Shuffle builds its systems backwards: it picks a small integer solution first and computes b\mathbf{b} from it, so the answers stay readable.

What Cramer's Rule Is

For a square system Ax=bA\mathbf{x} = \mathbf{b} with detA0\det A \neq 0, each unknown is a ratio of determinants:

xi=detAidetA,Ai=A with column i replaced by bx_i = \frac{\det A_i}{\det A}, \qquad A_i = A \text{ with column } i \text{ replaced by } \mathbf{b}


Why it works: the solution satisfies b=x1a1++xnan\mathbf{b} = x_1 \mathbf{a}_1 + \cdots + x_n \mathbf{a}_n, a combination of the columns of AA. Put that combination into column ii of AA and expand the determinant by linearity in that column: every term except the xiaix_i \mathbf{a}_i term has a repeated column and vanishes, and what remains is xidetAx_i \det A. So detAi=xidetA\det A_i = x_i \det A, and dividing gives the formula.

The same argument shows why detA0\det A \neq 0 is exactly the right condition. When it holds, the columns are independent and every b\mathbf{b} is reached by exactly one combination; when it fails, they are dependent, and b\mathbf{b} is reached either not at all or in infinitely many ways.

Cramer's rule is a theorem about the solution, not a recommended way to compute it. For nn unknowns it needs n+1n + 1 determinants, and computing determinants by expansion costs n!n! operations each. Its value is that it is a closed formula: it shows that each xix_i is a ratio of polynomials in the entries, which matters for symbolic work, for sensitivity analysis, and for small systems solved by hand. For solvability in general, see the linear systems theory page; for the rule among the other uses of the determinant, see the determinant applications page.

Key Properties

The rule inherits everything from the determinant.

Precondition: detA0\det A \neq 0; equivalently AA invertible, equivalently the columns independent
Uniqueness: when the rule applies, the solution it gives is the only one
Homogeneous case: b=0\mathbf{b} = \mathbf{0} forces every detAi=0\det A_i = 0 and hence x=0\mathbf{x} = \mathbf{0}; non-trivial solutions of Ax=0A\mathbf{x} = \mathbf{0} exist only when detA=0\det A = 0
Linearity in b\mathbf{b}: each xix_i is a linear function of b\mathbf{b}, which is the statement x=A1b\mathbf{x} = A^{-1}\mathbf{b} written entry by entry
Relation to the inverse: the rule is the adjugate formula A1=adjA/detAA^{-1} = \operatorname{adj} A / \det A applied to b\mathbf{b}
Scaling: multiplying an equation by a constant scales detA\det A and every detAi\det A_i by the same factor, leaving the ratios unchanged
Cost: n+1n + 1 determinants of size nn; by expansion that is (n+1)n!(n+1)\,n! operations against roughly 23n3\tfrac{2}{3}n^3 for elimination

Why It Matters

Cramer's rule is used where a formula is worth more than speed.

Small systems by hand: for 2×22 \times 2 and 3×33 \times 3 it is fast and self-checking, and it is the method behind many textbook shortcuts
Symbolic solutions: when the entries are parameters rather than numbers, the rule gives each unknown as an explicit rational function of them
Sensitivity: because each xix_i is a ratio of determinants, the effect of perturbing one coefficient can be read off directly
Theory: it is the shortest proof that a square system with non-zero determinant has exactly one solution, and it underlies the adjugate formula for the inverse
Geometry: in the plane, x1x_1 and x2x_2 are ratios of parallelogram areas, which is where the rule came from historically
The negative lesson: it is the standard example of a correct formula that is the wrong algorithm; solvers use elimination, and the rule explains why the answer exists

Worked Example

Take the default preset,

(111211121)x=(632)\begin{pmatrix} 1 & 1 & 1 \\ 2 & -1 & 1 \\ 1 & 2 & -1 \end{pmatrix} \mathbf{x} = \begin{pmatrix} 6 \\ 3 \\ 2 \end{pmatrix}


Determinant of AA, expanding along the first row: 1(12)1(21)+1(4+1)=1+3+5=71(1 - 2) - 1(-2 - 1) + 1(4 + 1) = -1 + 3 + 5 = 7. Non-zero, so the rule applies.

First unknown: replace column 11 by b\mathbf{b}.

detA1=611311221=6(12)1(32)+1(6+2)=6+5+8=7,x1=7/7=1\det A_1 = \begin{vmatrix} 6 & 1 & 1 \\ 3 & -1 & 1 \\ 2 & 2 & -1 \end{vmatrix} = 6(1 - 2) - 1(-3 - 2) + 1(6 + 2) = -6 + 5 + 8 = 7, \qquad x_1 = 7/7 = 1


Second unknown: replace column 22.

detA2=161231121=1(32)6(21)+1(43)=5+18+1=14,x2=14/7=2\det A_2 = \begin{vmatrix} 1 & 6 & 1 \\ 2 & 3 & 1 \\ 1 & 2 & -1 \end{vmatrix} = 1(-3 - 2) - 6(-2 - 1) + 1(4 - 3) = -5 + 18 + 1 = 14, \qquad x_2 = 14/7 = 2


Third unknown: replace column 33.

detA3=116213122=1(26)1(43)+6(4+1)=81+30=21,x3=21/7=3\det A_3 = \begin{vmatrix} 1 & 1 & 6 \\ 2 & -1 & 3 \\ 1 & 2 & 2 \end{vmatrix} = 1(-2 - 6) - 1(4 - 3) + 6(4 + 1) = -8 - 1 + 30 = 21, \qquad x_3 = 21/7 = 3


Check: 1+2+3=61 + 2 + 3 = 6, 22+3=32 - 2 + 3 = 3, 1+43=21 + 4 - 3 = 2. Four 3×33 \times 3 determinants for three unknowns; elimination would have needed a handful of row operations.

Common Mistakes

A few mistakes recur.

Replacing a row instead of a columnb\mathbf{b} goes into column ii; the columns of AA are the coefficient vectors of the unknowns, and xix_i multiplies column ii
Forgetting to check detA\det A first — if it is zero every xix_i is a division by zero, and no amount of determinant arithmetic will rescue it
Reading detA=0\det A = 0 as "no solution" — it means no unique solution; the system may still be consistent with infinitely many, which row reduction decides
Dividing the wrong wayxi=detAi/detAx_i = \det A_i / \det A, the replaced determinant over the original
Using it on non-square systems — the rule needs as many equations as unknowns; other systems have no coefficient determinant to speak of
Using it for large systems — correct but ruinously slow; it is a formula for understanding and for small cases, not a solver