Cramer's Rule Calculator (2x2 and 3x3 Systems)

Enter the coefficients of a 2 × 2 or 3 × 3 linear system and this calculator solves it the way Cramer's rule does: one determinant for the coefficient matrix, one more for each unknown with its column replaced by the constants, and a division. You get every determinant separately, the values of x, y and z, a clear verdict when det A = 0 - inconsistent or dependent, which are different things - and an automatic substitution check on all three equations.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
System sizeChoose how many equations and unknowns you have.3 x 3 (x, y, z)
Equation 1 coefficientsThe coefficients of x, y and z in that order. Use 0 for a missing variable.2, 1, -1
Equation 2 coefficientsSame order as equation 1. Fractions such as 1/2 are accepted.-3, -1, 2
Equation 3 coefficientsIgnored when the system size is 2 x 2.-2, 1, 2
Right-hand side constantsThe constant from each equation, after moving all the variables to the left.8, -11, -3

It returns

  • x — det Aₓ divided by det A.
  • y
  • z — Blank for a 2 x 2 system, which has no third unknown.
  • det A — Zero means there is no unique solution.
  • Verdict
  • Largest substitution error — How far the solution misses the original equations. Rounding only.

The formula

xi=det(Ai)det(A),det(A)0
D=a1b2a2b1

In plain text: xᵢ = det(Aᵢ) / det(A), where Aᵢ is A with column i replaced by b

  • AThe n × n matrix of coefficients
  • bThe column of constants on the right-hand side
  • AᵢA with its i-th column replaced by b
  • xᵢThe i-th unknown: x, y or z

Requires a square system with det A ≠ 0. If det A = 0 the rule does not apply and the system must be analysed by row reduction.

Updated Category Matrices & Linear Algebra Verified against published test cases Reading time 10 min

What Cramer's rule does

Cramer's rule solves a square system of linear equations by writing each unknown as a ratio of two determinants. For the system Ax = b with A square and det A ≠ 0, the i-th unknown is

xᵢ = det(Aᵢ) / det(A)

where Ai is the coefficient matrix with its i-th column replaced by the constants b. Nothing is eliminated, nothing is substituted; you compute n + 1 determinants and divide.

That makes it the tidiest hand method for 2 × 2 and 3 × 3 systems, which is why it survives in statics, circuit analysis and analytic geometry courses. Solve a truss joint for three unknown member forces, or a two-loop circuit for its mesh currents, and Cramer's rule gets you there with less bookkeeping than elimination and with no chance of losing a sign while swapping rows.

It also does something elimination does not: it tells you immediately how sensitive the answer is. The determinant of the coefficient matrix sits in every denominator, so a small determinant means every unknown is a ratio with a small denominator, and small changes in the data produce large changes in the answer. You see the conditioning of the problem before you see the solution.

The determinants, and what det A = 0 means

For a 2 × 2 system

a₁x + b₁y = c₁, a₂x + b₂y = c₂

the three determinants are D = a₁b₂ − a₂b₁, Dₓ = c₁b₂ − c₂b₁ and Dₖ = a₁c₂ − a₂c₁, giving x = Dₓ/D and y = Dₖ/D. For a 3 × 3 system the same recipe applies with 3 × 3 determinants, expanded by cofactors along any row or column.

Geometrically, det A is the signed volume of the parallelepiped spanned by the rows of A - or the area of the parallelogram, in two dimensions. When that volume is zero, the rows are linearly dependent: the planes described by the equations either share a whole line, or are parallel and never meet. Either way there is no single point to return.

The two failure cases are worth distinguishing, and this calculator does distinguish them. If det A = 0 and at least one replaced determinant is non-zero, the system is inconsistent and has no solution whatever. If det A = 0 and every replaced determinant is also zero, Cramer's rule gives no information: the system is dependent, and it may have infinitely many solutions or none at all. The 0/0 pattern is genuinely indeterminate, and the only way to settle it is to row-reduce the augmented matrix and look for a contradictory row. Any source that tells you 0/0 means infinitely many solutions is wrong - the system x + y = 1, x + y = 2, 2x + 2y = 3 has every determinant zero and no solution.

Why does the rule work? Multiply Ax = b on the left by the adjugate of A. Since adj(A)·A = det(A)·I, this gives det(A)·x = adj(A)·b, and the i-th entry of the right-hand side is exactly the cofactor expansion of det(Aᵢ). Cramer's rule is the adjugate formula for the inverse, written one component at a time.

Worked example: a 3 × 3 system

Solve

2x + y − z = 8
−3x − y + 2z = −11
−2x + y + 2z = −3

  1. det A. Expand along the first row: 2[(−1)(2) − (2)(1)] − 1[(−3)(2) − (2)(−2)] + (−1)[(−3)(1) − (−1)(−2)] = 2(−4) − 1(−2) − 1(−5) = −8 + 2 + 5 = −1. Non-zero, so there is a unique solution.
  2. det Aₓ - replace column 1 with the constants: 8[(−1)(2) − (2)(1)] − 1[(−11)(2) − (2)(−3)] + (−1)[(−11)(1) − (−1)(−3)] = 8(−4) − 1(−16) − 1(−14) = −32 + 16 + 14 = −2.
  3. det Aₖ - replace column 2: 2[(−11)(2) − (2)(−3)] − 8[(−3)(2) − (2)(−2)] + (−1)[(−3)(−3) − (−11)(−2)] = 2(−16) − 8(−2) − 1(−13) = −32 + 16 + 13 = −3.
  4. det A₣ - replace column 3: 2[(−1)(−3) − (−11)(1)] − 1[(−3)(−3) − (−11)(−2)] + 8[(−3)(1) − (−1)(−2)] = 2(14) − 1(−13) + 8(−5) = 28 + 13 − 40 = 1.
  5. Divide. x = −2/−1 = 2, y = −3/−1 = 3, z = 1/−1 = −1.

Check by substitution into the first equation: 2(2) + 3 − (−1) = 4 + 3 + 1 = 8. Second: −3(2) − 3 + 2(−1) = −6 − 3 − 2 = −11. Third: −2(2) + 3 + 2(−1) = −4 + 3 − 2 = −3. All three hold, which is the substitution check the calculator prints automatically.

Reading the determinants

The first number to look at is det A, not the solution. It answers the yes-or-no question - is there a unique solution - before any division happens, and its size tells you how much to trust the answer.

Compare |det A| with the size of the coefficients. For a 3 × 3 matrix whose entries are around 10, a determinant of a few hundred is healthy and a determinant of 0.001 is a warning: the rows are nearly dependent, the planes nearly parallel, and the intersection point is poorly defined. The calculator flags that case. In numerical work the proper measure is the condition number rather than the determinant, because scaling every equation by 1,000 multiplies a 3 × 3 determinant by 109 without changing the problem at all - but for hand-sized systems with comparable coefficients, a small determinant is a reliable warning.

The substitution check is worth reading every time. The differences it reports should be zero to within rounding - typically below 10−12 for well-scaled input. Anything larger means a coefficient was mistyped, because Cramer's rule cannot produce a solution that fails its own equations except through arithmetic error.

Signs carry information too. Because each unknown is a ratio, changing the sign of det A alone would flip every unknown; in practice both determinants change together when you reorder rows, which is why swapping two equations leaves the solution untouched even though it flips the sign of every determinant involved.

What each determinant pattern tells you

Diagnosing a square linear system from its determinants alone.
det AReplaced determinantsVerdictGeometry (3 × 3)
≠ 0Any valuesExactly one solutionThree planes meeting at a single point
= 0At least one ≠ 0No solutionPlanes forming a prism, or parallel planes
= 0All = 0Indeterminate - row-reduce to decidePlanes sharing a line or a plane, or an inconsistent dependent set
≠ 0 but tinyAny valuesOne solution, poorly conditionedPlanes meeting at a very shallow angle
= 0 with b = 0All = 0Infinitely many (homogeneous)A line or plane of solutions through the origin

The third row is the case most references get wrong: all-zero determinants do not guarantee infinitely many solutions. x + y = 1 together with x + y = 2 has every determinant zero and no solution at all.

Pitfalls

  • Writing the equations in different variable orders. Every row must list the coefficients in the same order, with a zero wherever a variable is absent. 2x − z = 5 enters as 2, 0, -1.
  • Forgetting to move everything to the standard form. All variables on the left, all constants on the right, before you read off any coefficient.
  • Concluding infinitely many solutions from 0/0. All determinants zero means Cramer's rule is silent, not that the system is consistent. Row-reduce to settle it.
  • Using it on a large system. Cramer's rule costs O(n!) work if the determinants are expanded by cofactors, against O(n³) for Gaussian elimination. At n = 10 that is the difference between a few hundred operations and a few million.
  • Trusting it near singularity. Both numerator and denominator are computed as sums of products with cancellation, so a nearly singular system loses precision in the determinant before it loses it anywhere else.
  • Applying it to a non-square system. Cramer's rule needs as many equations as unknowns. For an over-determined system, least squares is the right tool; for an under-determined one, the solution set is a subspace and there is no single answer to report.

When to use something else

For anything larger than 3 × 3 by hand, or for any system solved by machine, elimination wins. Gauss-Jordan elimination solves the system and simultaneously tells you the rank, which is what actually settles the dependent case that Cramer's rule leaves open. LU decomposition does the same work in a form you can reuse across many right-hand sides.

If you need to solve the same coefficient matrix against several different constant vectors, computing the matrix inverse once and multiplying is usually more efficient than repeating Cramer's rule - though in production numerical work you factorise rather than invert, because forming an explicit inverse costs more and is less accurate than a triangular solve.

The determinant itself has uses well beyond solving systems. The determinant calculator covers the expansion rules in detail, and the same quantity appears as the scale factor in a change of variables, as the characteristic polynomial in the eigenvalue problem, and as the scalar triple product a · (b × c) in vector geometry, which is why three vectors are coplanar exactly when that determinant vanishes.

Gabriel Cramer published the rule in 1750 in his treatise on algebraic curves, using it to fit a curve through a set of prescribed points - a linear system in the unknown coefficients. Colin Maclaurin had written down the 2 × 2 and 3 × 3 cases earlier, in work published posthumously in 1748. The rule predates matrix notation by a century; determinants came first, and matrices were invented later to organise them.

Frequently asked questions

When should I use Cramer's rule instead of elimination?

For 2 × 2 and 3 × 3 systems solved by hand, especially when you want a specific unknown rather than all of them - you can compute just det A and the one replaced determinant you need. Beyond 3 × 3, elimination is faster, more accurate and gives you the rank as a by-product. No serious numerical library uses Cramer's rule for solving.

What does it mean when det A = 0?

It means the coefficient matrix is singular and the system has no unique solution. Two sub-cases follow. If any replaced determinant is non-zero, the system is inconsistent and has no solution at all. If every replaced determinant is also zero, the equations are dependent and the system has either infinitely many solutions or none - Cramer's rule cannot tell which, and you must row-reduce the augmented matrix to find out.

Can Cramer's rule solve a system with more equations than unknowns?

No. The rule requires a square coefficient matrix, because it is built from determinants and a determinant only exists for a square matrix. An over-determined system generally has no exact solution, and the standard approach is least squares - solve the normal equations, which are square, or use a QR factorisation. An under-determined system has a whole subspace of solutions, described by row reduction.

How do I enter an equation that is missing a variable?

Enter a zero coefficient. The equation 2x − z = 5 in a three-variable system is 2, 0, -1 with 5 on the right. Every row must list all n coefficients in the same variable order, or the determinants will be built from the wrong matrix. This is the single most common data-entry mistake with the method.

Why is my answer so sensitive to small changes in the numbers?

Because det A is small relative to the coefficients, which puts a small number in every denominator. Geometrically, the planes described by your equations meet at a very shallow angle, so their intersection point slides a long way when a plane tilts slightly. The calculator warns when this happens. It is a property of the problem, not of the method - elimination on the same system is equally sensitive.

Does the order of the equations matter?

No. Swapping two equations changes the sign of det A and of every replaced determinant, so the ratios that give the unknowns are unchanged. Reordering the variables does matter, because that changes which column is which - and if you reorder them in the coefficient rows you must reorder your reading of the answers to match.

What is the substitution check for?

It puts the computed solution back into each original equation and reports the difference from the right-hand side. Those differences should be at the level of floating-point rounding, typically below 10⁻¹². A visibly non-zero difference means a coefficient was mistyped, since a correctly solved system satisfies its own equations by construction. It is the cheapest error check available and takes one line of arithmetic per equation.

Is Cramer's rule ever used in real computation?

Rarely for solving, but the underlying identity matters. The adjugate formula it comes from is how you prove that the inverse of an integer matrix with determinant ±1 is also an integer matrix, and 2 × 2 and 3 × 3 closed forms derived from it appear inside graphics and geometry code where a fixed tiny system must be solved millions of times. At that size, the explicit formula beats a general solver on speed.

References

  • Linear Algebra and Its Applications, 6th ed. (Section 3.3, Cramer's Rule, Volume and Linear Transformations) — David C. Lay, Steven R. Lay and Judi J. McDonald, Pearson
  • Introduction to Linear Algebra, 6th ed. — Gilbert Strang, Wellesley-Cambridge Press
  • Matrix Computations, 4th ed. (Chapter 3, General Linear Systems) — Gene H. Golub and Charles F. Van Loan, Johns Hopkins University Press