Cramer's rule calculator
📥 Export options
Exporting...
Solve systems of linear equations using determinants with detailed step-by-step solutions
Cramer's rule is an explicit formula for solving systems of linear equations with as many equations as unknowns, using determinants. Named after Gabriel Cramer (1704-1752), this elegant method expresses the solution in terms of determinants of the coefficient matrix and matrices obtained by replacing columns with the constants vector.
Quick Navigation
What is Cramer's Rule?
Definition
Cramer's rule states that for a system of linear equations Ax = b with n equations and n unknowns, if the determinant of the coefficient matrix A is non-zero, then the unique solution is given by:
where A_i is the matrix formed by replacing the i-th column of A with the vector b.
Mathematical Foundation
Consider the system of linear equations:
a₁₁x₁ + a₁₂x₂ + ... + a₁ₙxₙ = b₁ a₂₁x₁ + a₂₂x₂ + ... + a₂ₙxₙ = b₂ ⋮ ⋮ ⋮ ⋮ aₙ₁x₁ + aₙ₂x₂ + ... + aₙₙxₙ = bₙ
📐 Geometric Interpretation
Each equation represents a hyperplane, and the solution is their unique intersection point when det(A) ≠ 0.
🎯 Direct Solution
Unlike elimination methods, Cramer's rule gives each variable directly without back-substitution.
🔢 Determinant-Based
The method relies entirely on determinant calculations, making it elegant but computationally intensive.
⚡ Unique Solution
Works only when det(A) ≠ 0, guaranteeing a unique solution exists.
The Cramer's Rule Formula
General Formula
For the system Ax = b, the solution for each variable x_i is:
where:
- det(A) is the determinant of the coefficient matrix
- det(A_i) is the determinant of the matrix obtained by replacing column i of A with vector b
- i = 1, 2, ..., n for n variables
Matrix Construction for Each Variable
For a 3×3 system with coefficient matrix A and constants vector b:
Original: A = [a₁₁ a₁₂ a₁₃] b = [b₁] [a₂₁ a₂₂ a₂₃] [b₂] [a₃₁ a₃₂ a₃₃] [b₃] For x₁: A₁ = [b₁ a₁₂ a₁₃] (replace column 1) [b₂ a₂₂ a₂₃] [b₃ a₃₂ a₃₃] For x₂: A₂ = [a₁₁ b₁ a₁₃] (replace column 2) [a₂₁ b₂ a₂₃] [a₃₁ b₃ a₃₃] For x₃: A₃ = [a₁₁ a₁₂ b₁] (replace column 3) [a₂₁ a₂₂ b₂] [a₃₁ a₃₂ b₃]
Step-by-Step Example: Complete Solution
Given System:
2x + y - z = 3 x - y + 2z = 1 3x + 2y + z = 10
Step 1 Write Coefficient Matrix and Constants
A = [2 1 -1] b = [3] [1 -1 2] [1] [3 2 1] [10]
Step 2 Calculate det(A)
det(A) = 2(-1×1 - 2×2) - 1(1×1 - 2×3) + (-1)(1×2 - (-1)×3) = 2(-1 - 4) - 1(1 - 6) + (-1)(2 + 3) = 2(-5) - 1(-5) + (-1)(5) = -10 + 5 - 5 = -10
Step 3 Calculate det(A₁) for x
A₁ = [3 1 -1] [1 -1 2] [10 2 1] det(A₁) = 3(-1×1 - 2×2) - 1(1×1 - 2×10) + (-1)(1×2 - (-1)×10) = 3(-5) - 1(-19) + (-1)(12) = -15 + 19 - 12 = -8
Step 4 Calculate det(A₂) for y
A₂ = [2 3 -1] [1 1 2] [3 10 1] det(A₂) = 2(1×1 - 2×10) - 3(1×1 - 2×3) + (-1)(1×10 - 1×3) = 2(-19) - 3(-5) + (-1)(7) = -38 + 15 - 7 = -30
Step 5 Calculate det(A₃) for z
A₃ = [2 1 3] [1 -1 1] [3 2 10] det(A₃) = 2(-1×10 - 1×2) - 1(1×10 - 1×3) + 3(1×2 - (-1)×3) = 2(-12) - 1(7) + 3(5) = -24 - 7 + 15 = -16
Step 6 Apply Cramer's Rule
y = det(A₂)/det(A) = -30/(-10) = 3
z = det(A₃)/det(A) = -16/(-10) = 1.6
Cramer's Rule for 2×2 Systems
Simplified Formula for 2×2
For the system:
a₁₁x + a₁₂y = b₁ a₂₁x + a₂₂y = b₂
The solution is:
y = (a₁₁b₂ - a₂₁b₁)/(a₁₁a₂₂ - a₂₁a₁₂)
System: 3x + 2y = 7 and x - y = 1
det(A) = |3 2| = 3(-1) - 2(1) = -5 |1 -1| det(A₁) = |7 2| = 7(-1) - 2(1) = -9 |1 -1| det(A₂) = |3 7| = 3(1) - 7(1) = -4 |1 1|
y = -4/(-5) = 0.8
Cramer's Rule for 3×3 Systems
Variable | Matrix Formation | Determinant Calculation | Formula |
---|---|---|---|
x | Replace column 1 with b | det(A₁) using cofactor expansion | x = det(A₁)/det(A) |
y | Replace column 2 with b | det(A₂) using cofactor expansion | y = det(A₂)/det(A) |
z | Replace column 3 with b | det(A₃) using cofactor expansion | z = det(A₃)/det(A) |
Computational Complexity
Operation Count
For an n×n system using Cramer's rule:
- Determinants needed: n + 1 (one for A, one for each variable)
- Operations per determinant: O(n!) using cofactor expansion
- Total complexity: O((n+1)×n!) - impractical for n > 3
Compare to Gaussian elimination: O(n³)
Limitations and Special Cases
When Cramer's Rule Fails
❌ Singular Matrix
If det(A) = 0, the system either has no solution or infinitely many solutions. Cramer's rule cannot be applied.
❌ Non-Square Systems
The system must have exactly n equations for n unknowns. Overdetermined or underdetermined systems require other methods.
⚠️ Near-Singular Matrices
When det(A) ≈ 0, numerical errors can be amplified, leading to inaccurate results.
🔢 Large Systems
Computational cost grows factorially with system size, making it impractical for n > 4.
💾 Memory Requirements
Must store n+1 matrices simultaneously, which can be memory-intensive.
🔄 No Intermediate Results
Unlike elimination, doesn't provide useful intermediate information like rank or row echelon form.
Alternative Methods Comparison
Method | Best For | Complexity | Advantages |
---|---|---|---|
Cramer's Rule | Small systems (n ≤ 3) | O(n!×n) | Direct formula, theoretical elegance |
Gaussian Elimination | General purpose | O(n³) | Efficient, provides rank info |
LU Decomposition | Multiple right-hand sides | O(n³) | Reusable factorization |
Matrix Inversion | Theoretical analysis | O(n³) | x = A⁻¹b, but numerically unstable |
Applications of Cramer's Rule
Theoretical Applications
📚 Mathematical Proofs
Used in theoretical linear algebra to prove existence and uniqueness of solutions
🎓 Education
Teaching tool for understanding the relationship between determinants and linear systems
✏️ Symbolic Computation
Exact solutions in computer algebra systems when working with symbolic variables
Practical Applications
⚡ Circuit Analysis
Solving small networks using Kirchhoff's laws, finding currents and voltages
🔺 Geometry
Finding intersection points of lines and planes, coordinate transformations
🎮 Computer Graphics
2D and 3D transformations, ray-triangle intersection in rendering
📊 Interpolation
Finding polynomial coefficients through given points (Vandermonde systems)
🔬 Chemistry
Balancing chemical equations, solving equilibrium concentrations
🏗️ Structural Analysis
Solving small truss systems for forces and displacements
Historical Context
Gabriel Cramer (1704-1752)
Swiss mathematician who published the rule in 1750 in his work "Introduction à l'analyse des lignes courbes algébriques". However, the method was independently discovered by Colin Maclaurin (1698-1746) and possibly known to Leibniz even earlier.
Frequently Asked Questions
Ready to Solve Your System with Cramer's Rule?
Use our calculator to apply Cramer's rule instantly, with all determinant calculations shown step by step!
Tips for Using Cramer's Rule
- For 2×2 systems, memorize the direct formulas - they're faster than matrix setup
- Use cofactor expansion along the row or column with most zeros
- Check your answer by substituting back into the original equations
- Keep exact fractions instead of decimals to avoid rounding errors
- For 3×3 determinants, use the rule of Sarrus as a shortcut
- Remember: column replacement order matters - A₁ for x₁, A₂ for x₂, etc.
- Use our Cramer's rule calculator to verify manual calculations
- Consider Gaussian elimination for systems larger than 3×3