Cramer's Rule Solver

JJ Ben-Joseph headshot JJ Ben-Joseph

What is Cramer’s rule?

Cramer’s rule is a formula-based method for solving small systems of linear equations using determinants. It works for square systems, where the number of equations equals the number of unknowns, and the determinant of the coefficient matrix is nonzero. This calculator focuses on the most practical cases: 2×2 and 3×3 systems.

Write a system of n equations in matrix form as:

A·x=b

Here, A is the coefficient matrix, x is the column vector of unknowns, and b is the column vector of constants on the right-hand side.

If the determinant of A, written det(A), is not zero, Cramer’s rule gives each unknown as a ratio of determinants. For a 3×3 system with variables x,y,z, the formulas are:

x = D D , y = Dy D , z = Dz D

where D is the determinant of the original coefficient matrix, and Dx, Dy, and Dz are determinants of matrices where the corresponding column has been replaced by the constants vector b.

How this Cramer’s rule solver works

The calculator expects your system in the following standard form:

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:

  1. Builds the coefficient matrix A from the aij values you enter.
  2. Computes the determinant det(A).
  3. Constructs the replacement matrices for each variable by swapping in the constants b1, b2, and b3 into the corresponding column.
  4. Computes the determinants of those replacement matrices.
  5. 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.

Using the solver for 2×2 systems

For a 2×2 system with variables x and y, write your equations as:

In the form:

For a 2×2 system, Cramer’s rule simplifies to the familiar formulas:

x = ba22 - ba12 a11a22 - a12a21 , y = a11b - a21b a11a22 - a12a21

The calculator handles these determinant computations for you automatically.

Using the solver for 3×3 systems

For three variables x,y,z, arrange your equations as:

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 example

Consider the system:

Map this into the form:

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 example (applied)

Suppose three products share a common resource, and we model their relationships as:

Enter the coefficients and constants as:

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 results

The output gives the numerical values of the variables, along with information about the determinant:

In sensitive cases, consider rescaling your variables, using higher-precision arithmetic, or solving the system with a more numerically stable method such as Gaussian elimination.

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 A-1 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.

Assumptions and limitations

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.

Fill in coefficients and constants.

Embed this calculator

Copy and paste the HTML below to add the Cramer's Rule Solver – Solve 2x2 and 3x3 Linear Systems of Equations to your website.