Skip to content

How to solve a system of equations with Gaussian elimination

6 min read

Short answer

Write the system as an augmented matrix, then use row operations to create zeros below each pivot until the matrix is in staircase (echelon) form. Read the last equation, solve it, and back-substitute upward. The three allowed operations are swapping rows, scaling a row, and adding a multiple of one row to another.

Gaussian elimination turns the augmented matrix into a staircase with zeros below the pivotsaugmented matrixrow ops000echelon formsolve the last row, then back-substitute
Gaussian elimination turns the system into a staircase: zeros below each pivot, so the last row gives one variable directly.

Why row operations are safe

Each allowed operation replaces the system by one with exactly the same solutions: swapping equations, multiplying an equation by a nonzero number, and adding a multiple of one equation to another change how the system looks, not what solves it. Elimination is just doing these on purpose to make the system triangular.

The procedure

  1. Write the augmented matrix [A∣b][A\mid\mathbf b].
  2. Pick the first pivot (top-left). Use row operations to make everything below it zero.
  3. Move to the next row and column and repeat.
  4. Back-substitute from the last equation upward.

If you reach a row [0 0 0∣c][0\ 0\ 0\mid c] with c≠0c\neq0 there is no solution. If a column has no pivot, that variable is free and there are infinitely many solutions.

Worked example

Solve x+y+z=6,2y+5z=−4,2x+5y−z=27.x+y+z=6,\quad 2y+5z=-4,\quad 2x+5y-z=27.

Augmented matrix: (1116025−425−127).\left(\begin{array}{ccc|c}1&1&1&6\\0&2&5&-4\\2&5&-1&27\end{array}\right). Step 1. R3→R3−2R1R_3\to R_3-2R_1:  (0, 3, −3∣15)\ (0,\ 3,\ -3\mid 15).

Step 2. R3→R3−32R2R_3\to R_3-\tfrac32R_2:  (0, 0, −212∣21)\ (0,\ 0,\ -\tfrac{21}{2}\mid 21).

Back-substitute. −212z=21⇒z=−2-\tfrac{21}{2}z=21\Rightarrow z=-2. Then 2y+5(−2)=−4⇒y=32y+5(-2)=-4\Rightarrow y=3. Then x+3−2=6⇒x=5x+3-2=6\Rightarrow x=5.

Check in the third original equation: 2(5)+5(3)−(−2)=272(5)+5(3)-(-2)=27 ✓. The solution is (x,y,z)=(5,3,−2)(x,y,z)=(5,3,-2).

Try it yourself

Solve x+y+z=3,x−y+z=1,2x+y−z=0x+y+z=3,\quad x-y+z=1,\quad 2x+y-z=0.

Show the answer

Subtract the second equation from the first: 2y=22y=2, so y=1y=1. The first two then give x+z=2x+z=2. The third becomes 2x+1−z=02x+1-z=0, i.e. 2x−z=−12x-z=-1. Adding to x+z=2x+z=2 gives 3x=13x=1, so x=13x=\tfrac13 and z=53z=\tfrac53. Check in the first equation: 13+1+53=3\tfrac13+1+\tfrac53=3 ✓.

Keep going with practice

Vidi's Linear Algebra & Probability course walks through elimination, and its matrix calculator can show the row-reduced form so you can check each step.