Skip to content

Cramer's Rule Calculator

Cramer's rule solves a system of linear equations by dividing determinants: each variable equals the determinant of the coefficient matrix with that variable's column replaced by the constants, divided by the determinant of the coefficient matrix. This Cramer's rule calculator solves 2×2 and 3×3 systems and shows every determinant step, so you can check homework or learn the method.

  • xᵢ = det(Aᵢ) ÷ det(A)
  • 2×2 and 3×3 systems
  • Exact fractions and D = 0 check

Your system

Enter the coefficients of each equation in standard form (ax + by + cz = d). Use 0 for a missing variable.

System

Size

Show

Equation 1: a₁x + b₁y (+ c₁z) = d₁
Equation 2
Equation 3
— solution

    Use the calculator above for your own numbers. Below, we explain how the Cramer's Rule calculator works, with worked examples and sources.

    What is Cramer's rule?

    Cramer's rule is a formula from linear algebra for solving a square system of linear equations – the same number of equations as unknowns – using determinants. Write the system as a coefficient matrix A, a column of unknowns and a column of constants. If det(A) is not zero, the system has exactly one solution and each unknown is xᵢ = det(Aᵢ) ÷ det(A), where Aᵢ is A with column i replaced by the constants.

    The rule is named after the Swiss mathematician Gabriel Cramer, who published it in 1750 in his book on algebraic curves. It is mainly a teaching and theory tool today: elegant for 2×2 and 3×3 systems, but slow for big ones.

    What is a determinant?

    A determinant is a single number calculated from a square matrix. For a 2×2 matrix with rows (a, b) and (c, d) it is ad − bc. Geometrically it measures how the matrix scales area (or volume in 3D); if it is zero, the rows are dependent and the matrix cannot be inverted. That is exactly why Cramer's rule needs D ≠ 0.

    Cramer's rule for 2×2 systems

    For a₁x + b₁y = d₁ and a₂x + b₂y = d₂:

    • D = a₁b₂ − a₂b₁
    • Dx = d₁b₂ − d₂b₁ (constants in the x column)
    • Dy = a₁d₂ − a₂d₁ (constants in the y column)
    • x = Dx ÷ D and y = Dy ÷ D

    Worked 2×2 example

    Solve 2x + 3y = 16 and 4x − y = 2. D = (2)(−1) − (4)(3) = −2 − 12 = −14. Dx = (16)(−1) − (2)(3) = −16 − 6 = −22. Dy = (2)(2) − (4)(16) = 4 − 64 = −60. So x = −22 ÷ −14 = 11/7 ≈ 1.571 and y = −60 ÷ −14 = 30/7 ≈ 4.286.

    Check: 2(11/7) + 3(30/7) = 22/7 + 90/7 = 112/7 = 16 ✓ and 4(11/7) − 30/7 = 44/7 − 30/7 = 2 ✓. Always substitute back – it catches sign errors instantly.

    Cramer's rule for 3×3 systems

    For three equations in x, y and z you need four 3×3 determinants: D from the coefficients, then Dx, Dy and Dz with the constants swapped into each column in turn. A 3×3 determinant can be found by cofactor expansion along the first row:

    • D = a₁(b₂c₃ − b₃c₂) − b₁(a₂c₃ − a₃c₂) + c₁(a₂b₃ − a₃b₂)
    • Note the alternating signs: +, −, +
    • The rule of Sarrus is a shortcut that works only for 3×3: add the three down-right diagonal products and subtract the three up-right products.

    Worked 3×3 example

    Solve 2x + y + z = 3, x − y − z = 0, x + 2y + z = 0.

    1. D = 2[(−1)(1) − (−1)(2)] − 1[(1)(1) − (−1)(1)] + 1[(1)(2) − (−1)(1)] = 2(1) − 1(2) + 1(3) = 3.
    2. Dx (constants 3, 0, 0 in column 1) = 3[(−1)(1) − (−1)(2)] − 1[0 − 0] + 1[0 − 0] = 3.
    3. Dy (constants in column 2) = 2[0 − 0] − 3[(1)(1) − (−1)(1)] + 1[0 − 0] = −6.
    4. Dz (constants in column 3) = 2[0 − 0] − 1[0 − 0] + 3[(1)(2) − (−1)(1)] = 9.
    5. x = 3 ÷ 3 = 1, y = −6 ÷ 3 = −2, z = 9 ÷ 3 = 3.

    Check the first equation: 2(1) + (−2) + 3 = 3 ✓.

    Word problems solved with Cramer's rule

    Ticket sales (2×2)

    A school sold 150 tickets – adult tickets at $12 and child tickets at $8 – for $1,560. Let x be adult and y child tickets: x + y = 150 and 12x + 8y = 1,560. D = (1)(8) − (12)(1) = −4. Dx = (150)(8) − (1,560)(1) = −360, so x = 90. Dy = (1)(1,560) − (12)(150) = −240, so y = 60. Check: 90 × $12 + 60 × $8 = $1,080 + $480 = $1,560 ✓.

    Splitting an investment (3×3)

    $10,000 is split across three accounts paying 2%, 3% and 5%, earning $360 a year, and the 5% account holds twice as much as the 2% account. Equations: x + y + z = 10,000; 2x + 3y + 5z = 36,000 (the interest equation × 100); −2x + z = 0. D = −3, Dx = −6,000, Dy = −12,000 and Dz = −12,000, giving x = $2,000, y = $4,000 and z = $4,000. Check: $40 + $120 + $200 = $360 ✓.

    When the main determinant is zero

    If D = 0, Cramer's rule cannot give an answer because you would divide by zero. That is not a calculation error – it tells you the system has no unique solution. There are two possibilities:

    ExampleWhat happensMeaning
    x + 2y = 4; 2x + 4y = 8Second equation is 2 × the firstInfinitely many solutions (same line)
    x + 2y = 4; 2x + 4y = 9Left sides proportional, right sides notNo solution (parallel lines)

    For 2×2 systems, if D = 0 and Dx and Dy are also 0, the equations are dependent; if D = 0 but Dx or Dy is not 0, they are inconsistent. For 3×3 systems all-zero determinants do not always guarantee infinitely many solutions, so the calculator checks the ranks of the matrices (or uses elimination) to decide.

    Cramer's rule vs other methods

    MethodBest forDrawback
    Cramer's rule2×2 and 3×3 systems, formulas with letters, quick exam checksNeeds n + 1 determinants; impractical beyond about 4×4
    SubstitutionWhen one equation already isolates a variableMessy with fractions and three or more variables
    Elimination (Gaussian)Any size; what software usesMore steps to write by hand
    Matrix inverseSame coefficients, many different constant columnsFinding the inverse is as much work as elimination

    For n equations, Cramer's rule needs n + 1 determinants. Expanding determinants by cofactors grows factorially, so a 10×10 system by hand is hopeless, while Gaussian elimination needs roughly n³/3 operations. Computers therefore use elimination (LU decomposition), but Cramer's rule remains valuable because it gives explicit formulas – for example, in deriving the inverse of a 2×2 matrix or in economics models solved symbolically.

    Common mistakes

    • Not writing equations in standard form first – move all variables to the left and constants to the right.
    • Skipping a missing variable: 3x − 2z = 7 means the y coefficient is 0.
    • Replacing a row instead of a column with the constants.
    • Losing the minus sign on the middle cofactor in a 3×3 expansion.
    • Dividing D by Dx instead of Dx by D.
    • Treating D = 0 as 'no solution' without checking for infinitely many.

    Cramer's rule with decimals

    Solve 0.5x + 1.2y = 3.1 and 1.5x − 0.4y = 1.3. D = (0.5)(−0.4) − (1.5)(1.2) = −0.2 − 1.8 = −2. Dx = (3.1)(−0.4) − (1.3)(1.2) = −1.24 − 1.56 = −2.8. Dy = (0.5)(1.3) − (1.5)(3.1) = 0.65 − 4.65 = −4. So x = −2.8 ÷ −2 = 1.4 and y = −4 ÷ −2 = 2. To avoid rounding errors by hand, you can multiply each equation by 10 first: 5x + 12y = 31 and 15x − 4y = 13 give the same solution.

    The general 2×2 solution

    Applied to ax + by = e and cx + dy = f with letters instead of numbers, Cramer's rule gives x = (ed − bf) ÷ (ad − bc) and y = (af − ec) ÷ (ad − bc). This is the same formula hidden inside the inverse of a 2×2 matrix, A⁻¹ = (1 ÷ (ad − bc)) × [[d, −b], [−c, a]] – which is why both fail when ad − bc = 0.

    Example from economics: market equilibrium

    Demand is Q = 100 − 2P and supply is Q = 20 + 3P. Rewrite in standard form: Q + 2P = 100 and Q − 3P = 20. D = (1)(−3) − (1)(2) = −5. DQ = (100)(−3) − (20)(2) = −340, so Q = 68. DP = (1)(20) − (1)(100) = −80, so P = 16. At a price of 16 the market clears with 68 units – check: 100 − 32 = 68 and 20 + 48 = 68 ✓. The same approach solves circuit currents from Kirchhoff's laws, mixture problems and many physics systems.

    The rule of Sarrus, step by step

    For a 3×3 matrix, write the first two columns again to the right of the matrix. Multiply along the three diagonals running down to the right and add them; multiply along the three diagonals running up to the right and subtract them. For the matrix with rows (2, 1, 1), (1, −1, −1), (1, 2, 1): down-right products are 2·(−1)·1 = −2, 1·(−1)·1 = −1 and 1·1·2 = 2, totalling −1; up-right products are 1·(−1)·1 = −1, 2·(−1)·2 = −4 and 1·1·1 = 1, totalling −4. D = −1 − (−4) = 3, matching the cofactor method. Sarrus only works for 3×3 matrices.

    How to check your answer

    Substitute the values back into every original equation, not just one. If each left side equals its right side, the solution is correct. With fractions, keep them exact until the end – rounding a decimal halfway through is the most common reason a check fails by a small amount.

    What the solution means geometrically

    Each linear equation in two unknowns is a line; the solution is where two lines cross. D ≠ 0 means the lines cross at exactly one point. In three unknowns each equation is a plane, and a unique solution is the single point where three planes meet. When D = 0, the lines are parallel or identical, or the planes meet along a line, in a plane, or not at all.

    Sources

    1. Cramer G. (1750) Introduction à l'analyse des lignes courbes algébriques – historical
    2. Strang G. – Introduction to Linear Algebra (determinants and Cramer's rule) – textbook

    Results are estimates for information only. Last reviewed: .

    Written & built by

    Zeeshan Nawaz

    Calculator Developer · Tuff Search

    Builds and tests Tuff Search calculators, turning official tax tables and published formulas into tools anyone can check.

    FAQ

    Frequently asked questions

    Quick answers about the Cramer's Rule calculator.

    Solving small square systems of linear equations – usually 2×2 or 3×3 – and writing explicit formulas for each unknown in terms of determinants.

    Still have a question? Email support@tuffsearch.com