Cramer's Rule Solver
Introduction: Cramer’s rule for small linear systems
This Cramer's rule calculator solves small square linear systems by turning each equation into determinant ratios. It is most useful when you want a transparent answer for a 2×2 or 3×3 system and you can write the equations in standard linear form.
For Cramer’s rule, write a system of n equations in matrix form as:
Formula: A · x = b
In this Cramer's rule setup, is the coefficient matrix, is the column vector of unknowns, and is the column vector of constants on the right-hand side.
If the determinant of , written , is not zero, Cramer’s rule gives each unknown as a ratio of determinants. For a 3×3 system with variables , the formulas are:
Formula: x = D_x / D, y = D_y / D, z = D_z / D
where is the determinant of the original coefficient matrix, and , , and are determinants of matrices where the corresponding column has been replaced by the constants vector .
How this Cramer’s rule solver works
This Cramer's rule solver reads the coefficients you enter, builds the coefficient matrix, and checks whether the determinant is nonzero before it tries to divide.
- For a 3×3 system:
a11 x + a12 y + a13 z = b1 a21 x + a22 y + a23 z = b2a31 x + a32 y + a33 z = b3
The entries a11, a12, etc., are the coefficients that multiply each variable; b1, b2, and b3 are the constants on the right-hand side. The solver:
- Builds the coefficient matrix from the
aijvalues you enter. - Computes the determinant .
- Constructs the replacement matrices for each variable by swapping in the constants
b1,b2, andb3into the corresponding column. - Computes the determinants of those replacement matrices.
- Divides each replacement determinant by the main determinant to produce the solution.
If the main determinant is exactly zero (or numerically extremely close to zero), the solver will report that there is no unique solution and Cramer’s rule does not apply.
How to use: Solving a 2×2 system with Cramer’s rule
For a 2×2 Cramer's rule problem with variables and , write your equations as:
a11 x + a12 y = b1a21 x + a22 y = b2
In this 2×2 form:
- Fill in
a11,a12, andb1from the first equation. - Fill in
a21,a22, andb2from the second equation. - Leave
a13,a23,a31,a32,a33, andb3as zero or blank. The solver will treat the missing third row and column appropriately for a 2-variable system.
For a 2×2 system, Cramer’s rule simplifies to the familiar formulas:
D = a11*a22 - a12*a21
x = (b1*a22 - a12*b2) / D
y = (a11*b2 - b1*a21) / D
The calculator handles these determinant computations for you automatically.
Using the solver for 3×3 linear systems
For a 3×3 Cramer's rule system, arrange the coefficients for across the three rows before entering them into the solver.
a11 x + a12 y + a13 z = b1a21 x + a22 y + a23 z = b2a31 x + a32 y + a33 z = b3
Then map each coefficient directly into the corresponding field. All nine aij entries and the three bi entries may be nonzero for a fully 3-dimensional problem.
Worked 2×2 Cramer’s rule example
Here is a simple 2×2 Cramer's rule system you can mirror in the calculator:
3x + 4y = 72x − y = 1
Map this into the form:
a11 = 3,a12 = 4,b1 = 7a21 = 2,a22 = -1,b2 = 1
Leave the remaining fields blank or zero. The determinant of the coefficient matrix is:
det(A) = 3 ⋅ (-1) − 4 ⋅ 2 = -11.
Replacing the first column with b gives det(A_x) = -11, and replacing the second column gives det(A_y) = -11. So:
x = det(A_x) / det(A) = (-11)/(-11) = 1
y = det(A_y) / det(A) = (-11)/(-11) = 1
If you enter these numbers into the calculator, it will display the same solution.
Worked 3×3 Cramer’s rule example (applied)
This 3×3 Cramer's rule example shows how the solver behaves when all three variables interact through the same set of coefficients.
2x + y + z = 4x + 3y - z = 33x - y + 2z = 7
Enter the coefficients and constants as:
a11 = 2,a12 = 1,a13 = 1,b1 = 4a21 = 1,a22 = 3,a23 = -1,b2 = 3a31 = 3,a32 = -1,a33 = 2,b3 = 7
The calculator builds the 3×3 matrix, computes its determinant and the three replacement determinants, then reports the unique solution for x, y, and z. You can change a single coefficient (for example, adjust a23) to see how sensitive the solution is to that entry.
Interpreting the Cramer's rule results
After you solve a Cramer's rule system, the output shows both the variable values and the main determinant that controls whether those values are valid:
- If the determinant is nonzero and reasonably sized, the system has a unique solution, and Cramer’s rule is reliable.
- If the determinant is exactly zero, there is no unique solution. The equations are either inconsistent (no solution) or dependent (infinitely many solutions).
- If the determinant is very small in magnitude (for example, |det(A)| < 10−6), the system is nearly singular and the solution can be extremely sensitive to rounding or measurement noise.
In sensitive Cramer's rule cases, check that the equations were entered with the correct signs and row order, and consider rescaling the coefficients or switching to a more numerically stable linear algebra method if the determinant is nearly zero.
Comparison with other methods
| Method | Best for | Advantages | Limitations |
|---|---|---|---|
| Cramer’s rule (this solver) | 2×2 and 3×3 systems | Direct formulas; conceptually simple; good for hand calculations and teaching determinants. | Computationally expensive for large systems; unstable if the determinant is very small. |
| Gaussian elimination | Medium to large systems | Scales efficiently; foundation of many numerical solvers for linear equations. | More algorithmic; less transparent as a closed-form formula. |
| Matrix inversion | Repeatedly solving systems with the same matrix | Once is known, solving new right-hand sides is fast. | Computing the inverse can be expensive and is unnecessary if you only need a single solution. |
Cramer’s rule assumptions and limitations
- Square system only: This Cramer's rule tool assumes the number of equations equals the number of unknowns, which is why it covers 2×2 and 3×3 systems rather than overdetermined or underdetermined cases.
- Nonzero determinant: Cramer’s rule requires . If the determinant is zero, the system has no unique solution.
- Numerical sensitivity: When the determinant is extremely small in magnitude, the system is ill-conditioned. Small errors in input can produce large changes in the output.
- Size of the system: The method is most practical for 2×2 and 3×3 problems. Larger systems are better handled with elimination or factorization methods.
- Floating-point arithmetic: The calculator uses standard floating-point operations, so results may include rounding error, especially for very large or very small coefficients.
For larger systems or more advanced numerical work, consider using a general linear systems solver based on Gaussian elimination or an LU decomposition method, and a dedicated determinant calculator when you only need determinants.
Formula: how the Cramer’s rule solution is assembled
For this Cramer's rule solver, the reported x, y, and z values come from determinant ratios rather than a generic black-box formula. Enter each coefficient into the matching aij field and each constant into the matching bi field, keeping the rows in the same order as the equations. The calculator decides whether it is solving a 2×2 or 3×3 system by looking at whether the third row and third column are left blank or set to zero.
Arcade Mini-Game: Cramer's Rule Coefficient Check
Use this quick arcade run to practice matching coefficients to the right equation row and avoiding sign mistakes before you solve a system.
Start the game, then use your pointer or arrow keys to catch coefficient entries that belong in the matrix and avoid misleading shortcuts.
