Cramer's Rule Solver
Solve a system of linear equations using Cramer's Rule — the determinant-based method.
What Is Cramer's Rule?
Cramer's Rule is a method for solving a system of n linear equations in n unknowns using determinants. For a system Ax = b, each unknown is given by:
where A_i is the matrix A with the i-th column replaced by the constants vector b. The rule applies only when det(A) ≠ 0.
2×2 Example: Full Walkthrough
Solve the system:
x + 3y = 10
Step 1: Compute det(A)
det(A) = 2×3 − 1×1 = 6 − 1 = 5
Step 2: Replace column 1 with b to find x
det(A_x) = 5×3 − 1×10 = 15 − 10 = 5
x = det(A_x) / det(A) = 5 / 5 = 1
Step 3: Replace column 2 with b to find y
det(A_y) = 2×10 − 5×1 = 20 − 5 = 15
y = det(A_y) / det(A) = 15 / 5 = 3
Solution: x = 1, y = 3
Check: 2(1) + 3 = 5 ✓ and 1 + 3(3) = 10 ✓
3×3 Example
For a 3×3 system, the same principle applies but with 3×3 determinants computed by cofactor expansion. For example, solve:
2x − y + z = 3
x + 2y − z = 2
Compute det(A), then det(A_x), det(A_y), det(A_z) by replacing each column with [6, 3, 2]. Divide each by det(A). The calculator above handles this automatically.
Cramer's Rule vs. Gaussian Elimination
| Feature | Cramer's Rule | Gaussian Elimination |
|---|---|---|
| Best for | 2×2 and 3×3 systems | Any size system |
| Computational cost | O(n!) — expensive for large n | O(n³) — efficient |
| Handles singular matrices | No (det = 0 not allowed) | Yes (identifies no/infinite solutions) |
| Theoretical use | Excellent (closed-form formula) | Less direct |
When to Use Cramer's Rule
- Small systems (2×2, 3×3): Fast and straightforward by hand.
- Theoretical derivations: The closed-form formula shows how each variable depends on the data.
- Sensitivity analysis: Changing one constant b_i only changes one determinant, making it easy to see the effect on each variable.
- Not recommended: For n > 4 by hand, or when det(A) might be zero.
Real-World Applications
- Circuit analysis: Kirchhoff's laws produce a system of linear equations for unknown currents — Cramer's Rule gives exact closed-form solutions.
- Structural engineering: Force equilibrium at joints in a truss gives a system; Cramer's Rule solves for member forces.
- Economics: Market equilibrium for multiple goods with interdependent demand can be modeled as a linear system.
- Computer graphics: Finding intersection points of lines/planes uses small linear systems where Cramer's Rule is efficient.
Frequently Asked Questions
What is Cramer's Rule?
Cramer's Rule solves a square linear system Ax = b using determinants: x_i = det(A_i) / det(A), where A_i is A with column i replaced by b. It requires det(A) ≠ 0.
When does Cramer's Rule work?
When the system has n equations and n unknowns, and det(A) ≠ 0 (unique solution exists).
What if det(A) = 0?
Cramer's Rule cannot be applied. Use Gaussian elimination to determine whether the system has no solution or infinitely many solutions.
Is Cramer's Rule efficient for large systems?
No. It requires computing n+1 determinants — very expensive for large n. Gaussian elimination (O(n³)) is far more efficient for n > 3.
What is the 2×2 Cramer's Rule formula?
For a₁x + b₁y = c₁ and a₂x + b₂y = c₂: det(A) = a₁b₂ − a₂b₁, x = (c₁b₂ − c₂b₁)/det(A), y = (a₁c₂ − a₂c₁)/det(A).