Understanding the Cramer's rule calculator — concept and principle
This calculator solves a square system of linear equations Ax = b with Cramer's rule, using determinants. It shows the main determinant D, each Dᵢ with b placed in column i, and every xᵢ = Dᵢ ÷ D. Use it for 2 × 2 and 3 × 3 systems in algebra and linear algebra courses, or to check an elimination solution.
How it is calculated
D = det(A)
Aᵢ = A with its i-th column replaced by b; Dᵢ = det(Aᵢ)
xᵢ = Dᵢ ÷ D, for i = 1 … n
- The rule applies only when D ≠ 0. If D = 0, the system has no solution or infinitely many, and row reduction is needed to decide which.
- For an n × n system, n + 1 determinants are evaluated. Rational inputs give exact fractions where possible.
The principle
The determinant measures how A scales volume. Replacing column i by b and comparing determinants isolates the i-th unknown: because b = x₁(column 1) + … + xₙ(column n), and a determinant is linear in each column while vanishing when two columns are equal, det(Aᵢ) works out to exactly xᵢ × det(A). Dividing gives xᵢ. The formula is elegant and gives closed-form answers for symbolic systems, but it is slow for large n compared with elimination.
Worked example
Default inputs: A = [2 1 −1; −3 −1 2; −2 1 2], b = (8, −11, −3).
- D = det(A) = −1.
- D₁ = det[8 1 −1; −11 −1 2; −3 1 2] = 8(−2 − 2) − 1(−22 + 6) − 1(−11 − 3) = −32 + 16 + 14 = −2.
- Likewise D₂ = −3 and D₃ = 1, so Dᵢ = −2, −3, 1.
- xᵢ = Dᵢ ÷ D = 2, 3, −1.
- Solution x = (2, 3, −1), from 4 determinants.
How to read the result
Substitute the solution back: 2(2) + 3 − (−1) = 8, −3(2) − 3 + 2(−1) = −11 and −2(2) + 3 + 2(−1) = −3, all as required. A determinant D close to zero relative to the entries warns that the system is nearly singular and the answer is sensitive to small changes in the data.
Common mistakes
- Replacing a row instead of a column with b.
- Using the wrong column for each unknown.
- Dividing D by Dᵢ instead of Dᵢ by D.
- Applying the rule when D = 0.
Frequently asked questions
What is Cramer's rule?
A formula xᵢ = det(Aᵢ) ÷ det(A) for the solution of a square system with det(A) ≠ 0.
What if the determinant is zero?
Cramer's rule does not apply; the system has no unique solution.
Is Cramer's rule practical for big systems?
No, it needs n + 1 determinants; elimination is far cheaper.
Sources: A. Davis, P. Zachlin et al., Coordinated Linear Algebra (University of Nebraska–Lincoln), §5.3 Cramer's Rule · D. Margalit & J. Rabinoff, Interactive Linear Algebra, §4.2