Gaussian elimination: removing the unknowns one at a time

26 min · 5 drills

In the textbook: Ch. 6.2 Das Lösen linearer Gleichungssysteme

Two or three unknowns and as many equations: the system is solved by removing the unknowns one at a time until the last is left, then substituting it back.

You need a system of equations when there are several unknowns and no single condition fixes them one by one. That happens whenever only totals are known: how much was sold in all and how much money is in the till, how much raw material went into the whole batch. In the exam such a system is either a task of its own or one step inside a bigger task.

A small café sold 10 drinks in one day, coffee at 3 € and tea at 2 €. In the evening the till holds 26 €.

How many of these drinks were coffee?

One condition is not enough: 10 drinks can be 5 + 5 and also 6 + 4. The takings alone decide nothing either. The answer comes only when you take both conditions at once.

If all 10 drinks were tea, the till would hold 10⋅2=20 €. Each coffee instead of a tea adds 1 €, and the till holds 6 € more. So there were 6 coffees and 4 teas. Check: 6⋅3+4⋅2=26. With two unknowns this reasoning is handy. With three you need a safer method: that is what this article is about.

Check yourself. A task at exam level: find z if x+y+z=6, 2x−y+3z=9 and 3x+2y−z=4.

A system of equations and its solution

Call the number of cups of coffee x and the number of cups of tea y. Each condition in the text becomes an equation:

x+y=10I: drinks in total3x+2y=26II: takings

Two equations in the same unknowns, taken together, are called a system of linear equations (German: lineares Gleichungssystem). “Linear” means that the unknowns are only multiplied by numbers and added: there is no x2 and no x⋅y. The equations are numbered with Roman numerals I, II, III in the order they are written.

Let us test two pairs of numbers:

  • x=8, y=2: in I 8+2=10, true; in II 3⋅8+2⋅2=24+4=28, not 26. The pair fits only I.
  • x=6, y=4: in I 6+4=10, true; in II 3⋅6+2⋅4=18+8=26, true. This pair fits both equations: 6 cups of coffee were sold.

A set of numbers, one for each unknown, that makes all the equations true at once is called a solution of the system.

Guessing was lucky here. With three unknowns and numbers like 1203 guessing does not work; you need a method that always leads to the answer.

Removing an unknown and why it is allowed

If the second equation had no y, the number x could be read off at once. Let us remove y, using only the fact that both equations are true. This is how Gaussian elimination (“Gauß-Verfahren”) works: the unknowns are removed one after another.

  • Equation I is true: x+y and 10 are the same number. Double both sides: 2x+2y=20. Equal numbers multiplied by 2 stay equal, so the new equation is true as well. It is written 2⋅I.
  • Equation II is true: 3x+2y equals 26. From equal numbers subtract equal numbers: from the left side of II subtract the left side of 2⋅I, from the right side of II the right side. The equality is kept.
  • 3x+2y and 2x+2y share the same term 2y. In the subtraction it disappears.

This step is written “II −2⋅ I”: subtract I, multiplied by 2, from II. Beside the equations it helps to keep a table of numbers only, because x and y stand in the same places in every row and only the numbers in front of them change. Such a table is called the augmented matrix (German: erweiterte Koeffizientenmatrix): a row is an equation, a column belongs to one unknown, the right-hand side stands behind the bar. Below, the same two café equations are written as such a table.

row I times 2

Augmented matrix of the café: twice I is subtracted from II, and 0 is left in column yxyIII2·I111032262220
Step 1 of 4Multiply I by 2

In front of y there is a 2 in II and a 1 in I. For y to disappear it needs the same number in front of it, so we multiply I by 2.

2⋅x+2⋅y=2⋅10, that is 2x+2y=20.

Why ask whether you can go back? If a step can be undone, the system before it and after it have the same solutions: none is lost, none is added. In the café it goes like this: add 2⋅I to the new row x=6 again and you get II. Each of the three steps that never change the solutions can be undone in the same way:

  1. swap two equations (swapping again restores the old order);
  2. multiply an equation by a number c other than 0 (multiplying by 1c brings the old equation back; not by 0: the equation would turn into 0=0, and there is no way back);
  3. subtract from one equation another one multiplied by a number (adding the same again brings the old equation back; adding means subtracting with a minus).

Every step acts on both sides of the equation, the right-hand side included. Removing an unknown with such steps is called elimination (German: Elimination).

If the coefficients are not 1. In the café there was a 1 in front of y in I, and multiplying one equation was enough. Usually you have to multiply both.

I 2x+3y=12, II 3x+2y=13. Remove x.

In front of x stand 2 and 3. A number divisible by both 2 and 3 is 6.

3⋅I: 6x+9y=36.

2⋅II: 6x+4y=26.

3⋅I−2⋅II, the terms with x: 6x−6x=0.

The terms with y: 9y−4y=5y.

On the right: 36−26=10. This gives 5y=10, so y=2.

In I: 2x+3⋅2=12, that is 2x+6=12.

2x=6, x=3. Check with II: 9+4=13.

If the first equation has no x at all, swap it with an equation that has x (step 1).

Trap: subtracting on the left but not on the right. In the café this gives x=26, then y=10−26=−16, and the check with II gives 3⋅26+2⋅(−16)=46 instead of 26. A negative number of cups already hints at the mistake.

Your turn1 of 5

From I: 2x+3y=7 and II: 5x+2y=12, x is removed with the step 5⋅I−2⋅II. Which equation results?

Staggered system: start with the equation that has one unknown

Elimination serves one purpose: to get an equation with only one unknown left. In the first exam task such an equation is already in the question:

Exam-style task

Gegeben ist das lineare Gleichungssystem in x1,x2,x3:

−2x1+3x2−3x3=63−2x2+3x3=−1202x3=−52

Berechnen Sie −x1+x2+x3.

  1. a)−50
  2. b)−44
  3. c)−36
  4. d)−57
  5. e)−27

The task asks for −x1+x2+x3, so all three unknowns are needed. The task is recognised by the shape of the system: the bottom equation has one unknown, the middle one two, the top one three. Such a system is called staggered, or in row echelon form: each following equation starts one unknown further to the right. There is nothing to eliminate here, that work has been done. What remains is back substitution (German: Rückwärtseinsetzen): start with the equation that has only one unknown; the number found turns the neighbouring equation into an equation in one unknown, and so on. Here that equation is at the bottom, so you go from the bottom up.

2x₃ = −52

Staggered system: the bottom row gives x₃, the middle row x₂, the top row x₁x₁x₂x₃−23−3630−23−120002−52
Step 1 of 4x₃ from the bottom equation

2x3=−52.

Divide both sides by 2: x3=−26.

The system 2x=8, −3x+y=−10, x+2y−z=3; the sum x+y+z is wanted. The equation with one unknown is at the top, so you start at the top.

2x=8, so x=4.

−3⋅4+y=−10, that is −12+y=−10.

y=−10+12=2.

4+2⋅2−z=3, that is 8−z=3.

−z=3−8=−5, so z=5.

x+y+z=4+2+5=11.

From the bottom up. The system I x+2y−z=3, II 3y+2z=16, III 4z=8: the equation with one unknown stands at the bottom. Find x+y+z.

Your turn2 of 5

For x,y,z: x−y+2z=9, 2y−z=1, 3z=9. What is x+y+z?

Your turn3 of 5

For x,y,z: 3x+y−z=6, −y+2z=7, −2z=−8. What is 2x−y?

Traps. The wrong options of the task above come about like this:

  • Coefficient lost, option (d), −57: in the middle equation the factor 3 in front of x3 was lost during substitution. Then −2x2−26=−120, x2=47, the top equation gives x1=78, and −78+47−26=−57. The top equation holds for these numbers, because x1 was computed from it. Check: substitute the numbers into the middle equation, with its coefficient 3: −2⋅47+3⋅(−26)=−172, not −120.
  • Check. Substituting the numbers found into all three equations rules out wrong options at once.

One unknown from three equations

Substituting from the bottom up only works when the steps are already there. In the second exam task there are no steps yet. You first build them by elimination, as in the café section:

Exam-style task

Gegeben ist das lineare Gleichungssystem

x−2y+2z=12x−y−z=43x−2y−z=5

Bestimmen Sie den Wert von z.

  1. a)2
  2. b)14
  3. c)4
  4. d)5
  5. e)10

Here three equations are given, each with all three unknowns, and the question is about one of them. There are no steps yet: they are made by elimination. The first equation removes x from the second and third. Two equations in y and z remain, which is the task from the café section. From them y is removed, and the last row contains only z. The new row after a step gets a prime: II′ means “the new second equation”. A row changed a second time gets two primes: III″.

II − 2·I

Gaussian elimination on three equations: first remove x from II and III, then y from III′xyzIIIIIIII′1−2212−1−143−2−1503−52
Step 1 of 4Remove x from II

In front of x there is a 2 in II and a 1 in I, so we compute II −2⋅ I.

2⋅I: 2x−4y+4z=2.

The terms with y: −y−(−4y)=3y. The terms with z: −z−4z=−5z. On the right: 4−2=2.

Row II′: 3y−5z=2.

The check with III takes half a minute, and it is needed: x and y also came out along the way, and both are among the wrong options.

The system I 2x+4y−2z=4, II 3x+y+z=8, III y+z=5. Find z.

All the numbers in I are divisible by 2. Divide (step 2 with the number 12): x+2y−z=2.

II −3⋅ I: 3⋅I is 3x+6y−3z=6.

y−6y=−5y, z−(−3z)=4z, on the right 8−6=2. Row II′: −5y+4z=2.

III has no x, so it is left alone.

In front of y stand −5 in II′ and 1 in III. 5⋅III: 5y+5z=25.

II′ +5⋅ III: −5y+5y=0, 4z+5z=9z, on the right 2+25=27.

9z=27, z=3.

From III: y=5−3=2. From I: x+4−3=2, x=1. Check with II: 3+2+3=8.

Remove y from III′. The system from “Check yourself”: I x+y+z=6, II 2x−y+3z=9, III 3x+2y−z=4. II −2⋅ I gives II′ −3y+z=−3. III −3⋅ I gives III′ −y−4z=−14. Find z.

Your turn4 of 5

Find z if x−y+2z=6, 2x+y+z=9 and 3x+2y−z=9.

Your turn5 of 5

Find x if 2x+y+z=7, 4x−y+2z=8 and 2x+3y−z=5.

Traps. The wrong options of the task above come about like this:

  • Giving the wrong unknown, options (c) 4 and (d) 5: these are y and x, they come out during the check. Check: circle the letter the question asks about.
  • Right-hand side not recomputed, option (e), 10: in II −2⋅ I the 4 was left on the right instead of 4−2=2. Then the last step gives 4⋅4−3⋅2=10. Check: write every step as a whole row, with the number behind the bar.
  • Sign on the right-hand side, option (b), 14: in the last step 8+6 was computed instead of 8−6. Check: substitute the answer and the x, y you found into III.

At a glance: steps and traps

The topic in a minute

  • System of linear equations: several equations in the same unknowns, which are only multiplied by numbers and added. Solution: numbers that make all the equations true at once.
  • Three steps that do not change the solutions: swap equations; multiply an equation by a number other than 0; subtract from an equation another one multiplied by a number. Every step is applied to the right-hand side too.
  • Elimination: multiply the rows so that the coefficients of an unknown match, and subtract. Trap: subtracting on the left and forgetting the right.
  • One unknown from three equations

    Three equations, each with all three unknowns, one of them is wanted. Remove x from II and III, then y from the new III.
    II′=II−2⋅I

    Trap: giving x or y when z is asked; not recomputing the right-hand side.

On the exam formula sheet there is no Gaussian elimination: you have to remember the steps yourself.

The systems in this article each had exactly one solution. There can also be none, or infinitely many, which is the subject of 'How many solutions a system has: none, one or infinitely many'.

Now practise it

Gaussian elimination: removing the unknowns one at a time

Trainer · Systems of linear equations

Practise
Next: How many solutions a system has: none, one or infinitely many
0/5

Was this article helpful?