Solving systems of linear equations: substitution, elimination and Gaussian elimination
A system of linear equations asks for values of several unknowns that satisfy every equation at once. Geometrically, two equations in x and y are two lines and the solution is where they cross; three equations in x, y and z are three planes. A system can have exactly one solution, no solution (parallel lines or planes) or infinitely many solutions (the same line or plane written twice).
This solver uses Gaussian elimination on the augmented matrix with exact fractions, the same algorithm taught in linear algebra courses and used inside most numerical software. Each column's row operations are listed, followed by a substitution check.
Key formulas
A x = bx = (b₁a₂₂ − a₁₂b₂)/det A, y = (a₁₁b₂ − b₁a₂₁)/det AWorked examples
2x + y − z = 8, −3x − y + 2z = −11, −2x + y + 2z = −3.
- Write the augmented matrix and eliminate x from rows 2 and 3.
- Eliminate y from rows 1 and 3 using the new row 2.
- Back-substitute or continue to reduced row echelon form.
3x + 2y = 12 and x − y = −1.
- Multiply the second equation by 2: 2x − 2y = −2.
- Add to the first: 5x = 10, so x = 2.
- Substitute: 2 − y = −1, so y = 3.
x + 2y = 3 and 2x + 4y = 7.
- Subtract twice the first equation from the second: 0 = 1.
A chemist needs 10 L of a 30% acid solution from 20% and 50% stock. How much of each?
- Let x = litres of 20%, y = litres of 50%.
- x + y = 10 and 0.2x + 0.5y = 3.
- From the first, x = 10 − y; then 2 − 0.2y + 0.5y = 3 → 0.3y = 1 → y = 10/3.
Substitution vs elimination vs matrices
Substitution (solve one equation for a variable and plug it into the others) is natural for two equations, especially when one variable has coefficient 1. Elimination (add multiples of equations to cancel a variable) scales better. Gaussian elimination is just elimination organized in a matrix, which is why it is the method of choice for three or more unknowns and for computers.
Reading the reduced matrix
- A row of zeros with a non-zero right-hand side (0 = c) means the system is inconsistent.
- A column without a pivot corresponds to a free variable: infinitely many solutions.
- A pivot in every variable column means a unique solution, read directly from the last column.
Common mistakes to avoid
- Applying a row operation to only part of a row (including forgetting the right-hand side).
- Sign errors when subtracting a negative multiple.
- Dividing by a pivot that is zero — swap rows first.
- Stopping at echelon form and misreading the values without back-substitution.
Frequently asked questions
How many equations do I need?
Why does the solver use fractions?
Can it solve nonlinear systems?
Related tools and guides
Educational content. Results are computed in your browser with standard double-precision arithmetic; double-check anything with legal, financial, medical, or safety consequences. Spotted an error? Tell us and we will correct it.