System of Equations Solver
Solve 2×2 and 3×3 linear systems by Gaussian elimination.
Solved by Gaussian elimination with partial pivoting.
A system of equations is solved by the values that satisfy all of them at once. For 2x + y = 5 and x − y = 1, adding the equations cancels y to give 3x = 6, so x = 2; back-substituting gives y = 1. That point (2, 1) is where the two lines cross.
Where the lines meet
A linear system asks for the values that satisfy every equation at once — geometrically, the point where two lines (or three planes) intersect. By hand you might use elimination; for a clean 2×2 system, Cramer’s rule gives each variable as a ratio of determinants. This solver uses Gaussian elimination with partial pivoting for numerical stability.
Cramer’s rule: D is the coefficient determinant; Dₓ, D_y replace a column with the constants
Worked example
Solve the system 2x + y = 5 and x − y = 1 by elimination:
- 1 Add the two equations to eliminate y. (2x + y) + (x − y) = 5 + 1 → 3x = 6, so x = 2.
- 2 Back-substitute x into either equation. From x − y = 1: 2 − y = 1, so y = 1.
- 3 Check with Cramer’s rule. D = 2(−1) − 1(1) = −3, Dₓ = 5(−1) − 1(1) = −6, D_y = 2(1) − 5(1) = −3 → x = −6 ÷ −3 = 2, y = −3 ÷ −3 = 1. ✓
What the determinant tells you (2×2)
For a·x + b·y = e and c·x + d·y = f, the coefficient determinant is D = ad − bc.
| Coefficient determinant D | Solutions | Geometry |
|---|---|---|
| Non-zero (≠ 0) | Exactly one (unique) | Lines cross at one point |
| Zero, consistent | Infinitely many | Same line (overlap) |
| Zero, inconsistent | None | Parallel, never meet |
When there is no unique solution
Determinant zero means singular. The equations are either redundant (the same line, infinitely many solutions) or contradictory (parallel lines, no solution). The solver flags this case rather than returning a false answer.
3×3 systems work the same way. Three planes meet at a single point when the coefficient determinant is non-zero; otherwise they share a line, a plane, or nothing at all.
Partial pivoting keeps it stable. Reordering rows to put the largest coefficient on the diagonal avoids dividing by tiny numbers, which protects accuracy with messy decimals.