Gaussian elimination, step by step

The standard way to solve a system of linear equations by hand, with a complete worked example.

The idea

A system with three unknowns is hard to solve all at once. Gaussian elimination makes it easier one unknown at a time: use one equation to remove x from all the equations below it, then use another to remove y, and so on. You end up with a “staircase” system where the last equation has only one unknown. Solve that, then work back up.

The three allowed moves

You can change a system in these three ways without changing its solution:

  1. Swap two equations.
  2. Multiply or divide every term of an equation by the same non-zero number.
  3. Add or subtract a multiple of one equation to another.

Every step of the method is one of these moves. Textbooks often write equations as rows, R1, R2, R3, and call the term you use to eliminate an unknown the pivot. On this site we write Eq 1, Eq 2, Eq 3 and highlight that term instead.

Worked example

Solve:

Eq 1:   2x +  y −  z =   8
Eq 2:  −3x −  y + 2z = −11
Eq 3:  −2x +  y + 2z =  −3

Step 1: remove x from Eq 2 and Eq 3

Use Eq 1, since its x term is 2x. To cancel −3x in Eq 2, add 3/2 × Eq 1 to it:

(−3x − y + 2z) + 3/2 × (2x + y − z) = −11 + 3/2 × 8
                   1/2 y + 1/2 z = 1

To cancel −2x in Eq 3, add Eq 1 to it:

(−2x + y + 2z) + (2x + y − z) = −3 + 8
                       2y + z = 5

Step 2: remove y from Eq 3

Now use the new Eq 2, 1/2 y + 1/2 z = 1. Subtract 4 × Eq 2 from Eq 3:

(2y + z) − 4 × (1/2 y + 1/2 z) = 5 − 4 × 1
                           −z = 1

The system is now in staircase (row echelon) form:

2x +     y −     z = 8
      1/2 y + 1/2 z = 1
                 −z = 1

Step 3: back-substitute

Step 4: check

Substitute x = 2, y = 3, z = −1 into the original equations: 4 + 3 + 1 = 8 ✓, −6 − 3 − 2 = −11 ✓, −4 + 3 − 2 = −3 ✓.

Run this example in the solver to see the same steps worked automatically. It loads by default.

Gaussian vs Gauss–Jordan elimination

Gaussian elimination stops at the staircase form and finishes with back-substitution. Gauss–Jordan elimination keeps going: it also clears the unknowns above each highlighted term and scales each one to 1, so the final system reads x = 2, y = 3, z = −1 directly. The solver on this site uses Gauss–Jordan, so its last step is the answer.

Common mistakes

What if it doesn't work out?

Sometimes elimination produces a row like 0 = 5, or a row of all zeros. Those mean the system has no solution or infinitely many. See unique, none, or infinitely many solutions.