Exercise: solving 3×3 systems by elimination
Goal
- Solve three equations in three unknowns \(x\), \(y\), \(z\) using Gaussian elimination.
- Practice writing the system as an augmented matrix and clearing it to upper-triangular form.
- Finish every problem with back-substitution and a check. Write down each row operation.
The method
A 3×3 system \(A\mathbf{x}=\mathbf{b}\) is
\[ \begin{aligned} a_{11}x + a_{12}y + a_{13}z &= b_1 \\ a_{21}x + a_{22}y + a_{23}z &= b_2 \\ a_{31}x + a_{32}y + a_{33}z &= b_3 \end{aligned} \]
We pack the coefficients and the right-hand side into an augmented matrix:
\[ \left[\begin{array}{ccc|c} a_{11} & a_{12} & a_{13} & b_1 \\ a_{21} & a_{22} & a_{23} & b_2 \\ a_{31} & a_{32} & a_{33} & b_3 \end{array}\right]. \]
Gaussian elimination uses row operations to create zeros below the diagonal:
- Use row 1 to make the entries below \(a_{11}\) zero (operations like \(\text{R2} \leftarrow \text{R2} - k\text{R1}\)).
- Use row 2 to make the entry below \(a_{22}\) zero (\(\text{R3} \leftarrow \text{R3} - k\text{R2}\)).
- You now have an upper-triangular matrix. The bottom row reads off \(z\) directly.
- Back-substitute: get \(z\), then \(y\), then \(x\).
- Check by plugging \(x,y,z\) into all three original equations.
A legal row operation is: replace a row by (that row) \(\pm\) (a multiple of another row). It does not change the solution.
Tiny worked example
\[ \begin{aligned} x + y + z &= 6 \\ \phantom{x +} y + z &= 5 \\ \phantom{x + y +} z &= 3 \end{aligned} \qquad \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & 1 & 1 & 5 \\ 0 & 0 & 1 & 3 \end{array}\right] \]
This is already upper-triangular. Back-substitute from the bottom:
- Row 3: \(z = 3\).
- Row 2: \(y + z = 5 \Rightarrow y + 3 = 5 \Rightarrow y = 2\).
- Row 1: \(x + y + z = 6 \Rightarrow x + 2 + 3 = 6 \Rightarrow x = 1\).
So \(x = 1,\ y = 2,\ z = 3\). Check: \(1+2+3=6\) ✓, \(2+3=5\) ✓, \(z=3\) ✓.
Problems
Write each system as an augmented matrix, eliminate to upper-triangular form showing each row operation, then back-substitute and check. Problems 1–3 are already triangular (back-substitution only). Problem 4 needs one elimination step; Problems 5–6 need two. The rest need three.
1. \(\begin{aligned} x + y + z &= 9 \\ y + z &= 7 \\ z &= 4 \end{aligned}\)
2. \(\begin{aligned} x + 2y + z &= 10 \\ y - z &= 1 \\ z &= 2 \end{aligned}\)
3. \(\begin{aligned} 2x + y + z &= 11 \\ 3y + z &= 8 \\ 2z &= 6 \end{aligned}\)
4. \(\begin{aligned} x + y + z &= 6 \\ 2x + 3y + z &= 11 \\ z &= 3 \end{aligned}\)
5. \(\begin{aligned} x + y + z &= 6 \\ x + 2y + z &= 8 \\ 2y + 3z &= 13 \end{aligned}\)
6. \(\begin{aligned} x - y + z &= 2 \\ 2x + y + z &= 7 \\ y + 2z &= 5 \end{aligned}\)
7. \(\begin{aligned} x + y + z &= 6 \\ x + 2y + 3z &= 14 \\ x + 4y + 9z &= 36 \end{aligned}\)
8. \(\begin{aligned} x + y + z &= 6 \\ 2x - y + z &= 3 \\ x + 2y - z &= 3 \end{aligned}\)
9. \(\begin{aligned} x + y + z &= 4 \\ 2x - y + z &= 7 \\ x + 2y + z &= 3 \end{aligned}\)
10. \(\begin{aligned} x + 2y - z &= 2 \\ 2x - y + z &= 3 \\ -x + y + 2z &= 6 \end{aligned}\)
Step through it
Type in any problem above (or use a random one) and step through the elimination with next ▶: each step names the row operation, shows the matrix before and after (pivot circled, changed row in yellow, the new 0 boxed in green) and writes out the row arithmetic. Use it to check your own steps after you have done them on paper. It starts on the \(3\times 3\) system from the lecture.
Hints
No row operations needed. Read \(z\) from the bottom row, substitute up into the middle row to get \(y\), then into the top row to get \(x\). In problem 3 the bottom row is \(2z = 6\), so divide by 2 first.
In problem 4, only one entry below the diagonal is nonzero: use \(\text{R2} \leftarrow \text{R2} - 2\text{R1}\) to kill the \(2x\), then back-substitute. Problems 5 and 6 each have two entries to clear. In problem 5, first use \(\text{R2} \leftarrow \text{R2} - \text{R1}\), then \(\text{R3} \leftarrow \text{R3} - 2\text{R2}\). In problem 6, use \(\text{R2} \leftarrow \text{R2} - 2\text{R1}\), then \(\text{R3} \leftarrow \text{R3} - \tfrac13\text{R2}\). Use the updated row 2 in each second operation.
Two eliminations under column 1, then one under column 2. Keep the pivot (top-left \(1\)) and subtract the right multiple of \(\text{R1}\) from \(\text{R2}\) and \(\text{R3}\) so both \(x\)-entries become 0. Then use the new \(\text{R2}\) to clear the \(y\)-entry in \(\text{R3}\).
The top-left pivot is already a \(1\). Clear column 1 with \(\text{R2} \leftarrow \text{R2} - 2\text{R1}\) and \(\text{R3} \leftarrow \text{R3} \pm \text{R1}\), then clear column 2 with a multiple of the new \(\text{R2}\). The middle pivot may be negative (like \(-3\) in problem 9); that is fine — just keep track of signs. Problem 10 lands on simple fractions over \(14\), which is expected.
Step-by-step solutions
Problem 1
\[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 9 \\ 0 & 1 & 1 & 7 \\ 0 & 0 & 1 & 4 \end{array}\right] \] Already triangular. Back-substitute:
- Row 3: \(z = 4\).
- Row 2: \(y + z = 7 \Rightarrow y + 4 = 7 \Rightarrow y = 3\).
- Row 1: \(x + y + z = 9 \Rightarrow x + 3 + 4 = 9 \Rightarrow x = 2\).
Answer: \(x = 2,\ y = 3,\ z = 4\). Check: \(2+3+4=9\) ✓, \(3+4=7\) ✓, \(z=4\) ✓.
Problem 2
\[ \left[\begin{array}{ccc|c} 1 & 2 & 1 & 10 \\ 0 & 1 & -1 & 1 \\ 0 & 0 & 1 & 2 \end{array}\right] \] Back-substitute:
- Row 3: \(z = 2\).
- Row 2: \(y - z = 1 \Rightarrow y - 2 = 1 \Rightarrow y = 3\).
- Row 1: \(x + 2y + z = 10 \Rightarrow x + 6 + 2 = 10 \Rightarrow x = 2\).
Answer: \(x = 2,\ y = 3,\ z = 2\). Check: \(2 + 2(3) + 2 = 10\) ✓, \(3 - 2 = 1\) ✓, \(z=2\) ✓.
Problem 3
\[ \left[\begin{array}{ccc|c} 2 & 1 & 1 & 11 \\ 0 & 3 & 1 & 8 \\ 0 & 0 & 2 & 6 \end{array}\right] \] Back-substitute:
- Row 3: \(2z = 6 \Rightarrow z = 3\).
- Row 2: \(3y + z = 8 \Rightarrow 3y + 3 = 8 \Rightarrow 3y = 5 \Rightarrow y = \tfrac{5}{3}\).
- Row 1: \(2x + y + z = 11 \Rightarrow 2x + \tfrac{5}{3} + 3 = 11 \Rightarrow 2x = 11 - \tfrac{14}{3} = \tfrac{19}{3} \Rightarrow x = \tfrac{19}{6}\).
Answer: \(x = \tfrac{19}{6},\ y = \tfrac{5}{3},\ z = 3\). Check: \(2(\tfrac{19}{6}) + \tfrac{5}{3} + 3 = \tfrac{19}{3} + \tfrac{5}{3} + 3 = 8 + 3 = 11\) ✓, \(3(\tfrac{5}{3}) + 3 = 5 + 3 = 8\) ✓, \(2(3) = 6\) ✓.
Problem 4
\[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 2 & 3 & 1 & 11 \\ 0 & 0 & 1 & 3 \end{array}\right] \] Eliminate the \(2\) in row 2, column 1: \(\text{R2} \leftarrow \text{R2} - 2\text{R1}\). \[ \text{R2}:\ (2-2,\ 3-2,\ 1-2 \mid 11-12) = (0,\ 1,\ -1 \mid -1). \] \[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & 1 & -1 & -1 \\ 0 & 0 & 1 & 3 \end{array}\right] \] Back-substitute:
- Row 3: \(z = 3\).
- Row 2: \(y - z = -1 \Rightarrow y - 3 = -1 \Rightarrow y = 2\).
- Row 1: \(x + y + z = 6 \Rightarrow x + 2 + 3 = 6 \Rightarrow x = 1\).
Answer: \(x = 1,\ y = 2,\ z = 3\). Check: \(1+2+3=6\) ✓, \(2(1)+3(2)+3 = 2+6+3 = 11\) ✓, \(z=3\) ✓.
Problem 5
\[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 1 & 2 & 1 & 8 \\ 0 & 2 & 3 & 13 \end{array}\right] \] Eliminate the \(1\) in row 2, column 1: \(\text{R2} \leftarrow \text{R2} - \text{R1}\). \[ \text{R2}:\ (1-1,\ 2-1,\ 1-1 \mid 8-6) = (0,\ 1,\ 0 \mid 2). \] \[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & 1 & 0 & 2 \\ 0 & 2 & 3 & 13 \end{array}\right] \] Now clear the \(2\) in row 3, column 2: \(\text{R3} \leftarrow \text{R3} - 2\text{R2}\). \[ \text{R3}:\ (0,\ 2-2,\ 3-0 \mid 13-4) = (0,\ 0,\ 3 \mid 9). \] \[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & 1 & 0 & 2 \\ 0 & 0 & 3 & 9 \end{array}\right] \] Back-substitute:
- Row 3: \(3z = 9 \Rightarrow z = 3\).
- Row 2: \(y = 2\).
- Row 1: \(x + y + z = 6 \Rightarrow x + 2 + 3 = 6 \Rightarrow x = 1\).
Answer: \(x = 1,\ y = 2,\ z = 3\). Check: \(1+2+3=6\) ✓, \(1+2(2)+3 = 1+4+3 = 8\) ✓, \(2(2)+3(3) = 4+9 = 13\) ✓.
Problem 6
\[ \left[\begin{array}{ccc|c} 1 & -1 & 1 & 2 \\ 2 & 1 & 1 & 7 \\ 0 & 1 & 2 & 5 \end{array}\right] \] Eliminate the \(2\) in row 2, column 1: \(\text{R2} \leftarrow \text{R2} - 2\text{R1}\). \[ \text{R2}:\ (2-2,\ 1-(-2),\ 1-2 \mid 7-4) = (0,\ 3,\ -1 \mid 3). \] \[ \left[\begin{array}{ccc|c} 1 & -1 & 1 & 2 \\ 0 & 3 & -1 & 3 \\ 0 & 1 & 2 & 5 \end{array}\right] \] Clear the \(1\) in row 3, column 2: \(\text{R3} \leftarrow \text{R3} - \tfrac{1}{3}\text{R2}\). \[ \text{R3}:\ \left(0,\ 1-1,\ 2-(-\tfrac{1}{3}) \,\middle|\, 5-1\right) = \left(0,\ 0,\ \tfrac{7}{3} \,\middle|\, 4\right). \] \[ \left[\begin{array}{ccc|c} 1 & -1 & 1 & 2 \\ 0 & 3 & -1 & 3 \\ 0 & 0 & \tfrac{7}{3} & 4 \end{array}\right] \] Back-substitute:
- Row 3: \(\tfrac{7}{3}z = 4 \Rightarrow z = \tfrac{12}{7}\).
- Row 2: \(3y - z = 3 \Rightarrow 3y = 3 + \tfrac{12}{7} = \tfrac{33}{7} \Rightarrow y = \tfrac{11}{7}\).
- Row 1: \(x - y + z = 2 \Rightarrow x = 2 + y - z = 2 + \tfrac{11}{7} - \tfrac{12}{7} = 2 - \tfrac{1}{7} = \tfrac{13}{7}\).
Answer: \(x = \tfrac{13}{7},\ y = \tfrac{11}{7},\ z = \tfrac{12}{7}\). Check: \(\tfrac{13}{7} - \tfrac{11}{7} + \tfrac{12}{7} = \tfrac{14}{7} = 2\) ✓; \(2(\tfrac{13}{7}) + \tfrac{11}{7} + \tfrac{12}{7} = \tfrac{26+11+12}{7} = \tfrac{49}{7} = 7\) ✓; \(\tfrac{11}{7} + 2(\tfrac{12}{7}) = \tfrac{11+24}{7} = \tfrac{35}{7} = 5\) ✓.
Problem 7
\[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 1 & 2 & 3 & 14 \\ 1 & 4 & 9 & 36 \end{array}\right] \] Clear column 1: \(\text{R2} \leftarrow \text{R2} - \text{R1}\) and \(\text{R3} \leftarrow \text{R3} - \text{R1}\). \[ \text{R2}:\ (0,\ 1,\ 2 \mid 8), \qquad \text{R3}:\ (0,\ 3,\ 8 \mid 30). \] \[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & 1 & 2 & 8 \\ 0 & 3 & 8 & 30 \end{array}\right] \] Clear column 2 below the pivot: \(\text{R3} \leftarrow \text{R3} - 3\text{R2}\). \[ \text{R3}:\ (0,\ 3-3,\ 8-6 \mid 30-24) = (0,\ 0,\ 2 \mid 6). \] \[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & 1 & 2 & 8 \\ 0 & 0 & 2 & 6 \end{array}\right] \] Back-substitute:
- Row 3: \(2z = 6 \Rightarrow z = 3\).
- Row 2: \(y + 2z = 8 \Rightarrow y + 6 = 8 \Rightarrow y = 2\).
- Row 1: \(x + y + z = 6 \Rightarrow x + 2 + 3 = 6 \Rightarrow x = 1\).
Answer: \(x = 1,\ y = 2,\ z = 3\). Check: \(1+2+3=6\) ✓; \(1 + 2(2) + 3(3) = 1+4+9 = 14\) ✓; \(1 + 4(2) + 9(3) = 1+8+27 = 36\) ✓.
Problem 8
\[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 2 & -1 & 1 & 3 \\ 1 & 2 & -1 & 3 \end{array}\right] \] Clear column 1: \(\text{R2} \leftarrow \text{R2} - 2\text{R1}\) and \(\text{R3} \leftarrow \text{R3} - \text{R1}\). \[ \text{R2}:\ (0,\ -3,\ -1 \mid -9), \qquad \text{R3}:\ (0,\ 1,\ -2 \mid -3). \] \[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & -3 & -1 & -9 \\ 0 & 1 & -2 & -3 \end{array}\right] \] Clear column 2 below the pivot: \(\text{R3} \leftarrow \text{R3} + \tfrac{1}{3}\text{R2}\). \[ \text{R3}:\ \left(0,\ 1 + \tfrac{1}{3}(-3),\ -2 + \tfrac{1}{3}(-1) \,\middle|\, -3 + \tfrac{1}{3}(-9)\right) = \left(0,\ 0,\ -\tfrac{7}{3} \,\middle|\, -6\right). \] \[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 6 \\ 0 & -3 & -1 & -9 \\ 0 & 0 & -\tfrac{7}{3} & -6 \end{array}\right] \] Back-substitute:
- Row 3: \(-\tfrac{7}{3}z = -6 \Rightarrow z = \tfrac{18}{7}\).
- Row 2: \(-3y - z = -9 \Rightarrow -3y = -9 + \tfrac{18}{7} = -\tfrac{45}{7} \Rightarrow y = \tfrac{15}{7}\).
- Row 1: \(x + y + z = 6 \Rightarrow x = 6 - \tfrac{15}{7} - \tfrac{18}{7} = 6 - \tfrac{33}{7} = \tfrac{9}{7}\).
Answer: \(x = \tfrac{9}{7},\ y = \tfrac{15}{7},\ z = \tfrac{18}{7}\). Check: \(\tfrac{9+15+18}{7} = \tfrac{42}{7} = 6\) ✓; \(2(\tfrac{9}{7}) - \tfrac{15}{7} + \tfrac{18}{7} = \tfrac{18-15+18}{7} = \tfrac{21}{7} = 3\) ✓; \(\tfrac{9}{7} + 2(\tfrac{15}{7}) - \tfrac{18}{7} = \tfrac{9+30-18}{7} = \tfrac{21}{7} = 3\) ✓.
Problem 9
\[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 4 \\ 2 & -1 & 1 & 7 \\ 1 & 2 & 1 & 3 \end{array}\right] \] Clear column 1: \(\text{R2} \leftarrow \text{R2} - 2\text{R1}\) and \(\text{R3} \leftarrow \text{R3} - \text{R1}\). \[ \text{R2}:\ (2-2,\ -1-2,\ 1-2 \mid 7-8) = (0,\ -3,\ -1 \mid -1), \] \[ \text{R3}:\ (1-1,\ 2-1,\ 1-1 \mid 3-4) = (0,\ 1,\ 0 \mid -1). \] \[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 4 \\ 0 & -3 & -1 & -1 \\ 0 & 1 & 0 & -1 \end{array}\right] \] Clear column 2 below the pivot: \(\text{R3} \leftarrow \text{R3} + \tfrac{1}{3}\text{R2}\). \[ \text{R3}:\ \left(0,\ 1 + \tfrac{1}{3}(-3),\ 0 + \tfrac{1}{3}(-1) \,\middle|\, -1 + \tfrac{1}{3}(-1)\right) = \left(0,\ 0,\ -\tfrac{1}{3} \,\middle|\, -\tfrac{4}{3}\right). \] \[ \left[\begin{array}{ccc|c} 1 & 1 & 1 & 4 \\ 0 & -3 & -1 & -1 \\ 0 & 0 & -\tfrac{1}{3} & -\tfrac{4}{3} \end{array}\right] \] Back-substitute:
- Row 3: \(-\tfrac{1}{3}z = -\tfrac{4}{3} \Rightarrow z = 4\).
- Row 2: \(-3y - z = -1 \Rightarrow -3y - 4 = -1 \Rightarrow -3y = 3 \Rightarrow y = -1\).
- Row 1: \(x + y + z = 4 \Rightarrow x - 1 + 4 = 4 \Rightarrow x = 1\).
Answer: \(x = 1,\ y = -1,\ z = 4\). Check: \(1 + (-1) + 4 = 4\) ✓; \(2(1) - (-1) + 4 = 2 + 1 + 4 = 7\) ✓; \(1 + 2(-1) + 4 = 1 - 2 + 4 = 3\) ✓.
Problem 10
\[ \left[\begin{array}{ccc|c} 1 & 2 & -1 & 2 \\ 2 & -1 & 1 & 3 \\ -1 & 1 & 2 & 6 \end{array}\right] \] Clear column 1: \(\text{R2} \leftarrow \text{R2} - 2\text{R1}\) and \(\text{R3} \leftarrow \text{R3} + \text{R1}\). \[ \text{R2}:\ (0,\ -5,\ 3 \mid -1), \qquad \text{R3}:\ (0,\ 3,\ 1 \mid 8). \] \[ \left[\begin{array}{ccc|c} 1 & 2 & -1 & 2 \\ 0 & -5 & 3 & -1 \\ 0 & 3 & 1 & 8 \end{array}\right] \] Clear column 2 below the pivot: \(\text{R3} \leftarrow \text{R3} + \tfrac{3}{5}\text{R2}\). \[ \text{R3}:\ \left(0,\ 3 + \tfrac{3}{5}(-5),\ 1 + \tfrac{3}{5}(3) \,\middle|\, 8 + \tfrac{3}{5}(-1)\right) = \left(0,\ 0,\ \tfrac{14}{5} \,\middle|\, \tfrac{37}{5}\right). \] \[ \left[\begin{array}{ccc|c} 1 & 2 & -1 & 2 \\ 0 & -5 & 3 & -1 \\ 0 & 0 & \tfrac{14}{5} & \tfrac{37}{5} \end{array}\right] \] Back-substitute:
- Row 3: \(\tfrac{14}{5}z = \tfrac{37}{5} \Rightarrow z = \tfrac{37}{14}\).
- Row 2: \(-5y + 3z = -1 \Rightarrow -5y = -1 - 3(\tfrac{37}{14}) = -1 - \tfrac{111}{14} = -\tfrac{125}{14} \Rightarrow y = \tfrac{125}{70} = \tfrac{25}{14}\).
- Row 1: \(x + 2y - z = 2 \Rightarrow x = 2 - 2(\tfrac{25}{14}) + \tfrac{37}{14} = 2 - \tfrac{50}{14} + \tfrac{37}{14} = 2 - \tfrac{13}{14} = \tfrac{15}{14}\).
Answer: \(x = \tfrac{15}{14},\ y = \tfrac{25}{14},\ z = \tfrac{37}{14}\). Check: (row 1) \(\tfrac{15}{14} + 2(\tfrac{25}{14}) - \tfrac{37}{14} = \tfrac{15 + 50 - 37}{14} = \tfrac{28}{14} = 2\) ✓; (row 2) \(2(\tfrac{15}{14}) - \tfrac{25}{14} + \tfrac{37}{14} = \tfrac{30 - 25 + 37}{14} = \tfrac{42}{14} = 3\) ✓; (row 3) \(-\tfrac{15}{14} + \tfrac{25}{14} + 2(\tfrac{37}{14}) = \tfrac{-15 + 25 + 74}{14} = \tfrac{84}{14} = 6\) ✓.