Vertex Learn

Gaussian elimination

What this lesson covers

  • Write the system as an augmented matrix.
  • Row operations keep the same solutions.
  • Back substitute from the bottom row.
Key idea

Row operations

  • Swap rows.
  • Multiply a row by a number.
  • Add a multiple of one row to another.
Worked example

The same system

  • Write only the coefficients.
  1. [1 1 16], [2 −1 1 | 3], [1 2 −1 | 2]
  2. R2 − 2R1: [0 −3 −1−9]
  3. R3 − R1: [0 1 −2−4]
  4. R2 + 3R3: [0 0 −7−21]
  5. z = 3
  6. y − 2(3) = −4, so y = 2
  7. x = 1
Key idea

Try it: one step at a time

  • Press Next step. Each row operation creates a zero, until the bottom row gives z.
Key idea

3D grapher

Worked example

A second system

  • Reduce [1 1 1 | 6], [1 2 3 | 14], [1 3 6 | 25].
  1. R2 − R1: [0 1 28]
  2. R3 − R1: [0 2 519]
  3. R3 − 2R2: [0 0 13]
  4. z = 3
  5. y + 2(3) = 8, so y = 2
  6. x = 1
Key idea

Try it: what the answer looks like

Common mistakes

  • Changing only one side of a row.
    Apply the operation across the whole row.
  • Overwriting the row you need next.
    Keep the working tidy, row by row.
Key idea

Try it: pick the row operation

Your turn

1

R1 is [1 1 1 | 2] and R2 is [2 1 3 | 5]. Find R2 − 2R1.

2

The bottom row is [0 0 2 | 8]. Find z.

3

Which is not a valid row operation?

4

A row is [0 1 1 | 6] and z = 4. Find y.

5

Write 2x − y + 3z = 7, x + 4z = 5 and 3y − z = 2 as an augmented matrix.

6

R1 is [1 1 1 | 2] and R2 is [2 3 1 | 9]. A student writes R2 − 2R1 as [0 1 −1 | 9]. What is the mistake?

7

R1 is [1 2 1 | 4], R2 is [0 1 3 | 5] and R3 is [0 3 2 | 1]. Which operation makes the next zero below the diagonal?

8

After elimination the rows are [1 2 −1 | 3], [0 1 3 | 11] and [0 0 2 | 6]. Find x, y and z.

Show answer

1. [0 −1 1 | 1] 2. z = 4 3. Multiplying a row by 0 4. y = 2 5. [2 −1 3 | 7], [1 0 4 | 5], [0 3 −1 | 2]. Keep x, y, z in columns, write 0 for a missing variable and keep each sign. 6. The right side should be 5, not 9: the operation applies to the whole row, so 9 − 2(2) = 5. 7. R3 − 3R2, which gives [0 0 −7 | −14]. Using R2 keeps the 0 already in R3 and removes the 3. 8. x = 2, y = 2, z = 3. 2z = 6 gives z = 3, y + 3(3) = 11 gives y = 2, and x + 2(2) − 3 = 3 gives x = 2.

Your turn

Sample question: Achieved

Use Gaussian elimination to solve the system with augmented matrix rows [1 1 1 | 4], [2 3 1 | 4] and [3 1 2 | 11].

Hint

Use R1 to make zeros under its leading 1, then use the new R2 to make a zero in R3.

Answer

x = 2, y = −1, z = 3

Step by step
  1. Each row is one equation: the first three numbers are the coefficients of x, y and z, and the last is the right-hand side.
  2. Aim: zeros in the bottom-left corner, so the last row has only z.
  3. R2 − 2R1: [0 1 −1 | −4]. Do the whole row, right-hand side included: 4 − 8 = −4.
  4. R3 − 3R1: [0 −2 −1 | −1].
  5. Now use the new R2 to clear the y in R3. R3 + 2R2: [0 0 −3 | −9].
  6. The bottom row says −3z = −9, so z = 3.
  7. Back substitute into R2: y − z = −4, so y − 3 = −4 and y = −1.
  8. R1: x + y + z = 4, so x − 1 + 3 = 4 and x = 2.
  9. Check in the original rows: 2 − 3 + 3 = 4 and 6 − 1 + 6 = 11. Both correct.
Full working
  1. R2 − 2R1: [0 1 −1 │ −4]
  2. R3 − 3R1: [0 −2 −1 │ −1]
  3. R3 + 2R2: [0 0 −3 │ −9]
  4. z = 3bottom row
  5. y − 3 = −4, so y = −1back substitute
  6. x = 4 − (−1) − 3 = 2
  7. x = 2, y = −1, z = 3
Your turn

Sample questions: Merit

1

Use Gaussian elimination to solve 2y + z = 8, x + y − z = −3 and 2x − y + 3z = 8.

Hint

The first equation has no x, so swap the first two rows before you start.

Answer

x = −1, y = 2, z = 4

Step by step
  1. Write the augmented matrix: [0 2 1 | 8], [1 1 −1 | −3], [2 −1 3 | 8].
  2. The top-left entry is 0, so it cannot clear the x below it. Swapping rows is a valid row operation, so swap R1 and R2.
  3. Now R1 = [1 1 −1 | −3], R2 = [0 2 1 | 8], R3 = [2 −1 3 | 8].
  4. R2 already has a 0 in front. Clear R3: R3 − 2R1 = [0 −3 5 | 14].
  5. To clear the −3 using the 2 in R2, avoid fractions: 2R3 + 3R2 = [0 0 13 | 52].
  6. So 13z = 52 and z = 4.
  7. R2: 2y + 4 = 8, so y = 2.
  8. R1: x + 2 − 4 = −3, so x = −1.
  9. Classic mistake: dividing by the 0 in the top-left corner, or carrying on as if it were 1.
  10. Check the last equation: −2 − 2 + 12 = 8. Correct.
Full working
  1. swap R1 and R2: [1 1 −1 │ −3], [0 2 1 │ 8], [2 −1 3 │ 8]leading entry was 0
  2. R3 − 2R1: [0 −3 5 │ 14]
  3. 2R3 + 3R2: [0 0 13 │ 52]no fractions
  4. z = 4
  5. 2y + 4 = 8, so y = 2
  6. x = −3 − 2 + 4 = −1
  7. x = −1, y = 2, z = 4
2

Use Gaussian elimination to solve the system with augmented matrix rows [2 3 1 | 2], [4 −3 2 | 7] and [6 6 −1 | −1]. Give exact answers.

Hint

R2 − 2R1 and R3 − 3R1 clear x. Look closely at the new R2 before you go on.

Answer

x = 12, y = −13, z = 2

Step by step
  1. Clear x below R1. R2 − 2R1: [0 −9 0 | 3]. R3 − 3R1: [0 −3 −4 | −7].
  2. The new R2 has no z, so it already gives y: −9y = 3, so y = −13.
  3. Still finish the elimination to keep the method clear: 3R3 − R2 = [0 0 −12 | −24].
  4. So −12z = −24 and z = 2.
  5. Back substitute into R1: 2x + 3 × (−13) + 2 = 2, so 2x − 1 + 2 = 2.
  6. 2x = 1, so x = 12.
  7. Keep fractions as fractions. Writing −0.33 for y gives a check that does not quite work.
  8. Check R2: 4 × 12 − 3 × (−13) + 2 × 2 = 2 + 1 + 4 = 7. Correct.
  9. Check R3: 3 − 2 − 2 = −1. Correct.
Full working
  1. R2 − 2R1: [0 −9 0 │ 3]
  2. R3 − 3R1: [0 −3 −4 │ −7]
  3. 3R3 − R2: [0 0 −12 │ −24]
  4. z = 2, y = 3 ÷ (−9) = −13
  5. 2x − 1 + 2 = 2, so x = 12back substitute
  6. x = 12, y = −13, z = 2
Your turn

Sample questions: Excellence

1

The system x + y + z = 3, x + 2y + 3z = 6, 2x + 3y + kz = 10 has a parameter k. Use Gaussian elimination to find the values of k for which there is a unique solution, and find that solution in terms of k. What happens when k = 4? Hence find the value of k for which x = y.

Hint

Reduce to a bottom row of the form [0 0 (k − 4) | something], then think about when you may divide by k − 4.

Answer

Unique when k ≠ 4: x = 1k − 4, y = 3 − 2k − 4, z = 1k − 4. No solution when k = 4. x = y when k = 5

Step by step
  1. Augmented matrix: [1 1 1 | 3], [1 2 3 | 6], [2 3 k | 10].
  2. R2 − R1: [0 1 2 | 3]. R3 − 2R1: [0 1 k − 2 | 4].
  3. R3 − R2: [0 0 k − 4 | 1]. So (k − 4)z = 1.
  4. If k ≠ 4, divide: z = 1k − 4. That gives exactly one z, so the solution is unique.
  5. Back substitute: y = 3 − 2z = 3 − 2k − 4.
  6. x = 3 − y − z = 3 − 3 + 2k − 4 − 1k − 4 = 1k − 4.
  7. If k = 4, the bottom row reads 0 = 1, which is false. So there is no solution: the planes do not share a point.
  8. Hence x = y: 1k − 4 = 3 − 2k − 4, so 3k − 4 = 3 and k − 4 = 1. So k = 5.
  9. Then x = 1, y = 1, z = 1.
  10. Check with k = 5: 1 + 1 + 1 = 3, 1 + 2 + 3 = 6, 2 + 3 + 5 = 10. All correct.
  11. Classic mistake: dividing by k − 4 without saying k ≠ 4. That one value is the whole point of the question.
Full working
  1. R2 − R1: [0 1 2 │ 3]
  2. R3 − 2R1: [0 1 k − 2 │ 4]
  3. R3 − R2: [0 0 k − 4 │ 1]
  4. k ≠ 4: z = 1k − 4, y = 3 − 2k − 4, x = 1k − 4
  5. k = 4: 0 = 1, no solution
  6. x = y: 3k − 4 = 3, k = 5
  7. unique for k ≠ 4; none for k = 4; x = y when k = 5
2

A circle has equation x² + y² + Dx + Ey + F = 0 and passes through (1, 1), (5, 3) and (−1, 5). Use Gaussian elimination to find D, E and F. Hence find the centre and radius of the circle.

Hint

Substitute each point to get a linear equation in D, E and F. For the centre, complete the square in x and in y.

Answer

D = −4, E = −8, F = 10; centre (2, 4), radius √10

Step by step
  1. The unknowns are D, E and F. x and y are known for each point, so each point gives one linear equation.
  2. (1, 1): 1 + 1 + D + E + F = 0, so D + E + F = −2.
  3. (5, 3): 25 + 9 + 5D + 3E + F = 0, so 5D + 3E + F = −34.
  4. (−1, 5): 1 + 25 − D + 5E + F = 0, so −D + 5E + F = −26.
  5. Augmented matrix: [1 1 1 | −2], [5 3 1 | −34], [−1 5 1 | −26].
  6. R2 − 5R1: [0 −2 −4 | −24]. R3 + R1: [0 6 2 | −28].
  7. R3 + 3R2: [0 0 −10 | −100], so F = 10.
  8. R2: −2E − 40 = −24, so E = −8. R1: D − 8 + 10 = −2, so D = −4.
  9. The circle is x² + y² − 4x − 8y + 10 = 0. Complete the square: (x − 2)² − 4 + (y − 4)² − 16 + 10 = 0.
  10. So (x − 2)² + (y − 4)² = 10: centre (2, 4) and radius √10.
  11. Check one point: (5 − 2)² + (3 − 4)² = 9 + 1 = 10. It is on the circle.
Full working
  1. D + E + F = −2from (1, 1)
  2. 5D + 3E + F = −34from (5, 3)
  3. −D + 5E + F = −26from (−1, 5)
  4. R2 − 5R1: [0 −2 −4 │ −24], R3 + R1: [0 6 2 │ −28]
  5. R3 + 3R2: [0 0 −10 │ −100], F = 10
  6. E = −8, D = −4back substitute
  7. (x − 2)² + (y − 4)² = 10complete the square
  8. D = −4, E = −8, F = 10; centre (2, 4), radius √10
Summary

What to take away

  • Same maths, fewer letters.
  • Aim for zeros under the diagonal.

Challenge

1

Tama solved a system of three equations by Gaussian elimination, but only his last page survives. It says: "R1 unchanged. Step 1: R2 − 2R1 and R3 − 3R1. Step 2: R3 − 4R2, using the new R2. Result: [1 2 −1 | 4], [0 1 3 | 5], [0 0 2 | 6]." Find the original system of equations and its solution.

Hint

Undo the row operations in reverse order. Undo Step 2 first: if new R3 = old R3 − 4R2, then old R3 = new R3 + 4R2.

Answer

x + 2y − z = 4, 2x + 5y + z = 13, 3x + 10y + 11z = 38; solution x = 15, y = −4, z = 3

Step by step
  1. Row operations can be undone, so work backwards from the final matrix, last step first.
  2. Undo Step 2: the R3 before it was [0 0 2 | 6] + 4 × [0 1 3 | 5] = [0 4 14 | 26].
  3. Undo Step 1: original R2 = [0 1 3 | 5] + 2 × [1 2 −1 | 4] = [2 5 1 | 13], and original R3 = [0 4 14 | 26] + 3 × [1 2 −1 | 4] = [3 10 11 | 38].
  4. The solution is the same for the original and the final matrix. Bottom row: 2z = 6, so z = 3. Then y + 9 = 5, so y = −4. Then x − 8 − 3 = 4, so x = 15.
  5. Check in the original equations: 30 − 20 + 3 = 13 and 45 − 40 + 33 = 38. Both correct.
Full working
  1. R3 before Step 2 = [0 0 2 │ 6] + 4[0 1 3 │ 5] = [0 4 14 │ 26]undo R3 − 4R2
  2. original R2 = [0 1 3 │ 5] + 2[1 2 −1 │ 4] = [2 5 1 │ 13]undo R2 − 2R1
  3. original R3 = [0 4 14 │ 26] + 3[1 2 −1 │ 4] = [3 10 11 │ 38]undo R3 − 3R1
  4. 2z = 6, z = 3bottom row
  5. y + 3(3) = 5, y = −4
  6. x + 2(−4) − 3 = 4, x = 15
  7. x + 2y − z = 4, 2x + 5y + z = 13, 3x + 10y + 11z = 38; x = 15, y = −4, z = 3
2

The sum of the first n square numbers, S(n) = 1² + 2² + ... + n², is a cubic with no constant term: S(n) = an³ + bn² + cn. Use S(1), S(2) and S(3) and Gaussian elimination to find a, b and c exactly. Check your formula with n = 4, then use it to find 11² + 12² + ... + 20².

Hint

S(1) = 1, S(2) = 5 and S(3) = 14 each give one equation in a, b and c. For the last part, a sum from 11² to 20² is the difference of two values of S.

Answer

a = 13, b = 12, c = 16; S(4) = 30 checks; 11² + ... + 20² = 2870 − 385 = 2485

Step by step
  1. S(1) = 1 gives a + b + c = 1. S(2) = 5 gives 8a + 4b + 2c = 5. S(3) = 14 gives 27a + 9b + 3c = 14.
  2. R2 − 8R1 gives [0 −4 −6 | −3] and R3 − 27R1 gives [0 −18 −24 | −13].
  3. To clear the −18 without fractions, take 2R3 − 9R2: [0 0 6 | 1], so c = 16.
  4. Back substitute: −4b − 1 = −3, so b = 12. Then a = 1 − 12 − 16 = 13.
  5. Check n = 4: 643 + 8 + 46 = 30, and 1 + 4 + 9 + 16 = 30. Correct.
  6. 11² + ... + 20² = S(20) − S(10) = 2870 − 385 = 2485.
Full working
  1. [1 1 1 │ 1], [8 4 2 │ 5], [27 9 3 │ 14]n = 1, 2, 3
  2. R2 − 8R1: [0 −4 −6 │ −3]; R3 − 27R1: [0 −18 −24 │ −13]
  3. 2R3 − 9R2: [0 0 6 │ 1], c = 16no fractions until the end
  4. −4b − 6(16) = −3, b = 12
  5. a = 1 − 12 − 16 = 13
  6. S(4) = 643 + 162 + 46 = 30matches 1 + 4 + 9 + 16
  7. S(20) = 80003 + 4002 + 206 = 2870, S(10) = 385
  8. a = 13, b = 12, c = 16; 11² + ... + 20² = 2485
3

A thin metal plate has three inside points A, B and C in a row. The edge above all three is held at 60°C and the edge below at 20°C. The left edge next to A is at 40°C and the right edge next to C is at 80°C. When the temperatures settle, each inside point is the mean of its four neighbours (above, below, left, right). Use Gaussian elimination to find the three temperatures exactly. An engineer then wants C to be exactly 60°C, by changing only the right edge temperature R. Find R.

Hint

Write each point as the mean of its four neighbours, then multiply by 4. For the second part, C is now known and R is unknown, so the unknowns are A, B and R.

Answer

A = 2857 ≈ 40.7°C, B = 3007 ≈ 42.9°C, C = 3557 ≈ 50.7°C; R = 3443 ≈ 114.7°C

Step by step
  1. A = (60 + 20 + 40 + B) ÷ 4 gives 4A − B = 120. B = (60 + 20 + A + C) ÷ 4 gives −A + 4B − C = 80. C = (60 + 20 + B + 80) ÷ 4 gives −B + 4C = 160.
  2. Matrix rows [4 −1 0 | 120], [−1 4 −1 | 80], [0 −1 4 | 160]. Take 4R2 + R1: [0 15 −4 | 440]. Then 15R3 + new R2: [0 0 56 | 2840], so C = 284056 = 3557.
  3. Back substitute: 15B = 440 + 4 × 3557 = 45007, so B = 3007. Then 4A = 120 + 3007, so A = 2857.
  4. Second part: put C = 60 and leave R unknown. The A equation is unchanged, the B equation becomes −A + 4B = 140, and the C equation becomes 240 − B = 80 + R.
  5. From 4A − B = 120 and −A + 4B = 140: 4 × the second + the first gives 15B = 680, so B = 1363 and A = 1243.
  6. Then R = 160 − 1363 = 3443 ≈ 114.7°C.
Full working
  1. 4A − B = 120, −A + 4B − C = 80, −B + 4C = 160each point × 4
  2. 4R2 + R1: [0 15 −4 │ 440]
  3. 15R3 + R2: [0 0 56 │ 2840], C = 3557
  4. 15B = 440 + 14207 = 45007, B = 3007; A = (120 + 3007) ÷ 4 = 2857
  5. C = 60: 4A − B = 120, −A + 4B = 140, 4(60) − B = 60 + 20 + Runknowns A, B, R
  6. 15B = 680, B = 1363, A = 1243
  7. R = 240 − 80 − 1363 = 3443
  8. A = 2857, B = 3007, C = 3557 (about 40.7, 42.9, 50.7°C); R = 3443 ≈ 114.7°C

More challenge problems

Practice

Practise this

Worksheet with answersWithout answersDownload PDF
Report a mistake

More in AS 91587

Is your child on track?

Take the free placement test