Cramer's Rule Calculator
Solve a two by two linear system using determinants.
What it does
Cramer's rule solves a square system of linear equations using determinants. For two equations in two unknowns it gives a compact formula that shows exactly how the coefficients determine the answer.
Write the system as a times x plus b times y equals e, and c times x plus d times y equals f. The coefficient determinant is a d minus b c. It is the same determinant that appears when checking whether a 2 by 2 matrix has an inverse.
To find x, replace the first column of the coefficient matrix with the right side values e and f, then take that determinant. To find y, replace the second column instead. Divide each by the coefficient determinant.
This tool performs those three determinant calculations and reports the two unknowns. It stops with a clear message when the coefficient determinant is zero, because the rule cannot produce a unique answer in that case.
The rule is a teaching tool and a closed form for small systems. Numerical analysts usually prefer elimination or factorisation for larger matrices because determinants are slow and can lose accuracy.
How to use
- Write both equations in the form coefficient times x plus coefficient times y equals a number.
- Enter a and b from the first equation, then e on its right side.
- Enter c and d from the second equation, then f on its right side.
- Read x and y from the main results, with six decimal places.
- Check the three determinants below to see how each answer was built.
- Substitute x and y back into both equations to confirm the solution.
Formula
- a, b, c, d
- The coefficients of x and y in the two equations.
- e, f
- The numbers on the right side of the two equations.
- D
- The determinant of the coefficient matrix.
- Dx, Dy
- Determinants with the x column or y column replaced by the right side.
The determinant of [[p, q], [r, s]] is p s minus q r. The engine applies that rule to the coefficient matrix and to the two modified matrices, then divides. It rejects a determinant whose absolute value is below 1e-12 to avoid dividing by something that is effectively zero.
Worked example
Example: 2x + y = 5 and x + 3y = 11
Coefficients are a = 2, b = 1, e = 5, c = 1, d = 3 and f = 11.
- Coefficient determinant: D = 2 x 3 - 1 x 1 = 6 - 1 = 5.000000.
- Replace the x column: Dx = 5 x 3 - 1 x 11 = 15 - 11 = 4.000000.
- Replace the y column: Dy = 2 x 11 - 5 x 1 = 22 - 5 = 17.000000.
- First unknown: x = Dx / D = 4 / 5 = 0.800000.
- Second unknown: y = Dy / D = 17 / 5 = 3.400000.
- Check in equation 1: 2 x 0.8 + 3.4 = 5. Check in equation 2: 0.8 + 3 x 3.4 = 11.
- The tool reports x 0.800000 and y 3.400000.
Reference table
| Determinant | Matrix used | Value |
|---|---|---|
| D | [[2, 1], [1, 3]] | 5.000000 |
| Dx | [[5, 1], [11, 3]] | 4.000000 |
| Dy | [[2, 5], [1, 11]] | 17.000000 |
| x | Dx / D | 0.800000 |
| y | Dy / D | 3.400000 |
Limits
- The tool solves a 2 by 2 system only. Larger systems need a different method.
- If the coefficient determinant is zero, there is either no solution or infinitely many.
- Input values are limited to 1e9 in magnitude to keep the determinant stable.
- Results are floating point estimates shown to six decimal places.
Common mistakes
- Mixing the right side values into the coefficient matrix before computing D.
- Swapping the rows of the modified matrix, which changes the sign of the determinant.
- Ignoring a zero determinant and expecting the tool to guess a solution.
- Entering the right side numbers in the wrong order for the two equations.
- Rounding x and y too early when checking the solution by substitution.
Try it yourself
Quick checks. Answers sit tucked under each question.
For 2x + y = 5 and x + 3y = 11, what are x and y?
x = 0.8 and y = 3.4. The determinants are D = 5, Dx = 4 and Dy = 17.
What does D = 0 tell you?
The system has no unique solution. The tool reports an error rather than dividing by zero.
Compute D for a = 1, b = 2, c = 3, d = 4.
1 x 4 - 2 x 3 = -2. A negative determinant is fine and simply reverses orientation.
Questions
Who was Cramer?
Gabriel Cramer, a Swiss mathematician whose 1750 work gave the determinant rule for solving linear systems.
Does the rule work for three unknowns?
Yes, using 3 by 3 determinants, but the arithmetic grows quickly and elimination is usually preferred.
Why does a zero determinant mean no unique solution?
It means the two equation lines are parallel or identical, so they do not cross in one point.
Is this used in real computations?
Rarely for large systems. It is useful for small systems and for understanding how determinants relate to solutions.
Can the right side be zero?
Yes. If e and f are both zero and D is not zero, both determinants vanish and the answer is x = 0, y = 0.
Does the order of the equations matter?
No. Swapping both rows of every matrix changes the sign of all three determinants but leaves x and y unchanged.
Sources
- University of Nebraska Lincoln, Coordinated Linear Algebra: Cramer's Rule
- MIT OpenCourseWare, Gilbert Strang: ZoomNotes for Linear Algebra