Cramer's Rule Calculator
Solve $2\times 2$ and $3\times 3$ systems of linear equations using matrix determinants. Calculate exact fractional coordinates $(x, y, z)$, inspect step-by-step column substitutions, analyze singular cases ($D = 0$), and visualize geometric line intersections on the Cartesian plane.
How to Solve Linear Equations with Cramer's Rule
Cramer's Rule solves a system of n linear equations with n unknowns (AX = B) by computing determinants. If the main coefficient determinant D = det(A) is not zero, each variable is found via the ratio x_i = det(A_i) / D, where A_i is matrix A with its i-th column replaced by constant column B. If D = 0, the system has either infinitely many solutions (dependent) or no solution (inconsistent).
What is Cramer's Rule?
Cramer's Rule is an explicit closed-form algebraic theorem in linear algebra used to compute the unique solution of a square system of linear equations ($n$ equations in $n$ variables). Formulated by the mathematician Gabriel Cramer in 1750, it provides individual variable solutions directly without requiring row reductions or matrix inversions.
For any system written in compact matrix-vector notation $A\mathbf{x} = \mathbf{b}$, where $A$ is an $n \times n$ square coefficient matrix, $\mathbf{x}$ is the column vector of unknowns, and $\mathbf{b}$ is the vector of constants:
Here, $A_i$ represents the matrix generated by substituting the $i$-th column of $A$ with the constant vector $\mathbf{b}$.
2×2 System Formula and Step-by-Step Derivation
Consider the general system of two linear equations with two unknown variables $x$ and $y$:
a₂x + b₂y = c₂
Two straight lines in the 2D Cartesian plane.
Coefficient matrix A and constant vector b.
To solve using determinants, evaluate the three $2\times 2$ cross-multiplications:
- Main Determinant ($D$): Formed by the coefficients of $x$ and $y$: $D = a_1 b_2 - b_1 a_2$
- $x$-Numerator Determinant ($D_x$): Replace the first column with constant terms $c_1, c_2$: $D_x = c_1 b_2 - b_1 c_2$
- $y$-Numerator Determinant ($D_y$): Replace the second column with constant terms $c_1, c_2$: $D_y = a_1 c_2 - c_1 a_2$
- Exact Solutions: $x = \frac{D_x}{D}$ and $y = \frac{D_y}{D}$
3×3 System Expansion: Sarrus' Rule vs Laplace Cofactor Method
For a $3\times 3$ linear system with variables $x, y, z$:
The main determinant $D = \det(A)$ is computed by Laplace expansion along the first row:
Geometric Interpretation: Area, Volume, and Intersection of Lines/Planes
In analytic geometry, determinants represent spatial scale factors:
- 2D Linear Systems: Each equation $a_i x + b_i y = c_i$ defines a straight line. If $D \neq 0$, the normal vectors are linearly independent, and the two lines intersect at precisely one coordinate point $(x, y)$. The determinant $D$ is the signed area of the parallelogram spanned by the normal vectors.
- 3D Linear Systems: Each equation represents an infinite flat plane in 3D Euclidean space. When $D \neq 0$, the three planes are not parallel or co-planar along a single axis, intersecting at a unique spatial vertex $(x, y, z)$. Here, $D$ corresponds to the scalar triple product $\mathbf{a} \cdot (\mathbf{b} \times \mathbf{c})$, which represents the signed volume of the parallelepiped.
Singular Systems: Inconsistent vs Dependent Cases ($D = 0$)
When the determinant of the coefficient matrix equals zero ($D = 0$), the matrix is non-invertible (singular). Under Cramer's Rule, division by zero occurs, indicating one of two structural geometric relationships:
Every numerator determinant is also zero. In 2D, both equations represent the exact same line (coincident lines). In 3D, the three planes coincide or intersect along a continuous common line.
At least one numerator determinant is non-zero. In 2D, the lines are parallel and separated by a non-zero distance. In 3D, the planes form a triangular prism or parallel sheets that share zero common intersection points.
Step-by-Step Worked Examples
5x - y = 3
- D = (2)(-1) - (3)(5) = -2 - 15 = -17
- D_x = (8)(-1) - (3)(3) = -8 - 9 = -17
- D_y = (2)(3) - (8)(5) = 6 - 40 = -34
- x = D_x / D = -17 / -17 = 1
- y = D_y / D = -34 / -17 = 2
2x - y + z = 8
3x + y - z = 3
- D = 1((-1)(-1) - (1)(1)) - 2((2)(-1) - (1)(3)) + 3((2)(1) - (-1)(3)) = 1(0) - 2(-5) + 3(5) = 25
- D_x = 9(0) - 2(-11) + 3(11) = 0 + 22 + 33 = 50 → x = 50 / 25 = 2
- D_y = 1(-11) - 9(-5) + 3(-18) = -11 + 45 - 54 = -25 → y = -25 / 25 = -1
- D_z = 1(11) - 2(-18) + 9(5) = 11 + 36 + 45 = 75 → z = 75 / 25 = 3
Comparison: Cramer's Rule vs Other Linear Solvers
| Solving Method | Time Complexity | Primary Strengths | Key Limitations |
|---|---|---|---|
| Cramer's Rule | O((n+1)!) | Direct formulas, exact fractions, ideal for 2x2 & 3x3 systems | Cannot solve singular (D = 0) or non-square systems; slow for n ≥ 4 |
| Gaussian Elimination | O(n³) | Scales to massive systems, handles rectangular matrices | Intermediate row divisions cause floating-point roundoff errors |
| Matrix Inverse (A⁻¹b) | O(n³) | Efficient when solving multiple right-hand sides for same A | High matrix inversion calculation cost compared to direct elimination |
| Substitution / Elimination | O(n³) | Intuitive manual pencil-and-paper solving for small systems | Sign and algebra errors multiply rapidly for 3 or more variables |
Lead Developer & Founder of Basic Math Tools. Specializes in browser-native computational algorithms and applied mathematics.
Mathematics & curriculum specialists. Audited against standard algebraic and arithmetic principles.