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.
Cramer's rule — for a square system Ax=b with detA=0, xi=detAdetAi, where Ai is A with its i-th column replaced by b.
Coefficient matrix — A, holding the coefficients of the unknowns, one row per equation.
Right-hand side — b, the constants; shown in amber throughout the tool.
Replaced matrix — Ai, formed by swapping b into column i of A.
Unique solution — exactly one x; for a square system this happens exactly when detA=0.
Singular system — detA=0; the system has no solution or infinitely many, and Cramer's rule does not apply.
Homogeneous system — b=0; every detAi is then 0, and the unique solution is x=0.
Cost — n+1 determinants of size n, 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×2 and a 3×3 with integer solutions, one with fractional answers, a homogeneous one, and a singular one where the rule stops • Use the Size stepper for 2 or 3 equations; resizing keeps the existing entries and pads with the identity • Edit any entry of A or of 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, 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.
• System — Ax=b with the unknowns still symbolic • Determinant — detA is evaluated; a non-zero value licenses the rest • Replace — for each i, the matrix Ai is shown with b in column i, its determinant is evaluated, and xi=detAi/detA • Done — the solution vector fills, and Ax is recomputed to confirm it equals b
If detA=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=b written out: the coefficient matrix, the vector of unknowns still symbolic and greyed, and b in amber. At the default preset the system is 3×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.
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, and only square matrices have determinants. A system with more equations than unknowns, or fewer, needs other methods.
The colour of 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, 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, highlighted.
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 A are independent, so 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 A as a transformation, which is why a zero means collapse.
Replacing a Column
For each unknown xi, the tool forms Ai by swapping b into column i of A, evaluates detAi, and divides by detA.
The frozen picture below is the second unknown of the default preset: A2 with b in its middle column, detA2=14, and x2=14/7=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 xidetA, and the picture shows why. Column i of Ai is b, which equals x1a1+⋯+xnan; a determinant is linear in each column, so detAi splits into n pieces, and every piece except the xiai one has two equal columns and vanishes.
Each unknown costs a fresh n×n determinant. Nothing from detA1 helps with detA2, 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 A are proportional, detA=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.
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 xi would be a division by zero. Geometrically the two columns lie on one line, so the combinations x1a1+x2a2 only ever reach that line, and 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, not about A, and determinants of A cannot answer it. Row reducing the augmented matrix [A∣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 A and b, and the caption multiplies Ax back out to confirm it equals b.
The frozen picture below is the default preset solved: x=(1,2,3).
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+1 determinants, no sharing of work between them, and a formula at the end. It is the right tool for a 2×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 A is highlighted and the detA slot fills, accent if non-zero and muted if zero • In a replace scene, Ai is drawn between determinant bars with the swapped column in amber and highlighted; the detAi slot is primary, the detA slot secondary, and the xi slot accent, with an arrow from the swapped column to its determinant • In the done scene, the solution vector is highlighted next to A and b • Fractions are shown as a/b in a smaller font; the unknowns not yet found are shown in grey as x1,x2,… • 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×2, integers — two equations, three determinants, solution (1,3); the whole rule in its smallest form • 3×3, integers — four 3×3 determinants, solution (1,2,3); the default, and the size at which the cost of the method starts to show • 2×2, fractions — the same rule with a non-integer answer, (7/5,19/10); the determinants are integers, the ratios are not • Homogeneous — b=0, so every replaced matrix has a zero column and every xi=0 • Singular — the columns of A are proportional, detA=0, and the run stops with the explanation
Shuffle builds its systems backwards: it picks a small integer solution first and computes b from it, so the answers stay readable.
What Cramer's Rule Is
For a square system Ax=b with detA=0, each unknown is a ratio of determinants:
xi=detAdetAi,Ai=A with column i replaced by b
Why it works: the solution satisfies b=x1a1+⋯+xnan, a combination of the columns of A. Put that combination into column i of A and expand the determinant by linearity in that column: every term except the xiai term has a repeated column and vanishes, and what remains is xidetA. So detAi=xidetA, and dividing gives the formula.
The same argument shows why detA=0 is exactly the right condition. When it holds, the columns are independent and every b is reached by exactly one combination; when it fails, they are dependent, and 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 n unknowns it needs n+1 determinants, and computing determinants by expansion costs n! operations each. Its value is that it is a closed formula: it shows that each xi 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: detA=0; equivalently A invertible, equivalently the columns independent • Uniqueness: when the rule applies, the solution it gives is the only one • Homogeneous case: b=0 forces every detAi=0 and hence x=0; non-trivial solutions of Ax=0 exist only when detA=0 • Linearity in b: each xi is a linear function of b, which is the statement x=A−1b written entry by entry • Relation to the inverse: the rule is the adjugate formula A−1=adjA/detA applied to b • Scaling: multiplying an equation by a constant scales detA and every detAi by the same factor, leaving the ratios unchanged • Cost: n+1 determinants of size n; by expansion that is (n+1)n! operations against roughly 32n3 for elimination
Why It Matters
Cramer's rule is used where a formula is worth more than speed.
• Small systems by hand: for 2×2 and 3×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 xi 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, x1 and x2 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,
1211−1211−1x=632
Determinant of A, expanding along the first row: 1(1−2)−1(−2−1)+1(4+1)=−1+3+5=7. Non-zero, so the rule applies.
Check: 1+2+3=6, 2−2+3=3, 1+4−3=2. Four 3×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 column — b goes into column i; the columns of A are the coefficient vectors of the unknowns, and xi multiplies column i • Forgetting to check detA first — if it is zero every xi is a division by zero, and no amount of determinant arithmetic will rescue it • Reading detA=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 way — xi=detAi/detA, 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
Related Concepts
Determinant — the rule is made of determinants; the determinant tool shows how each one is evaluated.
Matrix inverse — the adjugate formula is Cramer's rule for every possible b at once.
Gaussian elimination — the practical way to solve the same system, and the way to classify it when detA=0.
Rank — full rank is the same as detA=0 for a square matrix.
Linear independence — of the columns of A, the geometric content of the precondition.
Homogeneous systems — the case b=0, where the rule gives only the trivial solution.
Solution sets — unique, none, or infinitely many, of which the rule handles the first.