Worked examples
The question
Question: solve x + 2y = 4 and x + y = 3 by Gaussian elimination.
x + 2y = 4①
We want the x and y that make both true.
x + y = 3②
We will use three moves on the rows.
Swap two rows.
Times a row by a number that is not 0.
Add a multiple of one row to another.
Each move keeps the equations true, like in elimination.
swap two rows
× a row by a number (not 0)
add a multiple of one row to another
1 Write the augmented matrix
Each row is one equation: the numbers in front of x and y, then the number on the right.
The bar stands for the = signs.
This is called an augmented matrix.
= [1, 2, 4; 1, 1, 3]
We call the rows R 1 and R 2.
Our goal: 1s down the diagonal, and 0s under them.
This shape is called row-echelon form.
Then we go back up, one letter at a time.
goal: 1s down the diagonal, 0s under them
2 Get 0s under the 1 in column 1
→ [1, 2, 4; 0, −1, −1]
Careful!
A row move works on the whole row, the number after the bar too.
That number is the right side of the equation.
Careful: the whole row, after the bar too
3 Get a 1 in row 2
→ [1, 2, 4; 0, 1, 1]
4 Back substitution
Start at the bottom.
Each row is an equation again.
Row 2 is 1y = 1, with 0 for the other letters.
So y = 1.
y = 1
Row 1 is the equation x + 2y = 4.
x + 2y = 4
We know y = 1.
We put it in.
x + 2 × 1 = 4
Work it out: x + 2 = 4.
x + 2 = 4
To remove the + 2, we take away 2 on both sides.
x + 2 − 2 = 4 − 2
So x = 2.
x = 2
We write it as (2, 1).
(x, y) = (2, 1)
5 Check
Let's check in every equation.
We put x = 2, y = 1 into ①.
① 2 + 2(1) = 2 + 2 = 4
We get 4, the same as the right side.
Now ②.
② 2 + 1 = 3
We get 3, the same as the right side.
Both work.
So the answer is right!
Let's look back.
First: write the augmented matrix.
Then: get 0s under the 1 in column 1.
Then: get a 1 in row 2.
Then: back substitution.
Last: check.
▶ Watch it solved
The question
Question: solve x + y + z = 6, 2x − y + z = 3 and x + 2y − z = 2 by Gaussian elimination.
x + y + z = 6①
2x − y + z = 3②
We want the x, y and z that make all three true.
x + 2y − z = 2③
We will use three moves on the rows.
Swap two rows.
Times a row by a number that is not 0.
Add a multiple of one row to another.
Each move keeps the equations true, like in elimination.
swap two rows
× a row by a number (not 0)
add a multiple of one row to another
1 Write the augmented matrix
Each row is one equation: the numbers in front of x, y and z, then the number on the right.
The bar stands for the = signs.
This is called an augmented matrix.
= [1, 1, 1, 6; 2, −1, 1, 3; 1, 2, −1, 2]
We call the rows R 1, R 2 and R 3.
Our goal: 1s down the diagonal, and 0s under them.
This shape is called row-echelon form.
Then we go back up, one letter at a time.
goal: 1s down the diagonal, 0s under them
2 Get 0s under the 1 in column 1
→ [1, 1, 1, 6; 0, −3, −1, −9; 0, 1, −2, −4]
Careful!
A row move works on the whole row, the number after the bar too.
That number is the right side of the equation.
Careful: the whole row, after the bar too
3 Get a 1 in row 2
→ [1, 1, 1, 6; 0, 1, −2, −4; 0, −3, −1, −9]
4 Get 0s under the 1 in column 2
→ [1, 1, 1, 6; 0, 1, −2, −4; 0, 0, −7, −21]
5 Get a 1 in row 3
→ [1, 1, 1, 6; 0, 1, −2, −4; 0, 0, 1, 3]
6 Back substitution
Start at the bottom.
Each row is an equation again.
Row 3 is 1z = 3, with 0 for the other letters.
So z = 3.
z = 3
Row 2 is the equation y − 2z = −4.
y − 2z = −4
We know z = 3.
We put it in.
y − 2 × 3 = −4
Work it out: y − 6 = −4.
y − 6 = −4
To remove the − 6, we add 6 on both sides.
y − 6 + 6 = −4 + 6
So y = 2.
y = 2
Row 1 is the equation x + y + z = 6.
x + y + z = 6
We know y = 2 and z = 3.
We put them in.
x + 2 + 3 = 6
Work it out: x + 5 = 6.
x + 5 = 6
To remove the + 5, we take away 5 on both sides.
x + 5 − 5 = 6 − 5
So x = 1.
x = 1
We write it as (1, 2, 3).
(x, y, z) = (1, 2, 3)
7 Check
Let's check in every equation.
We put x = 1, y = 2, z = 3 into ①.
① 1 + 2 + 3 = 6
We get 6, the same as the right side.
Now ②.
② 2(1) − 2 + 3 = 2 − 2 + 3 = 3
We get 3, the same as the right side.
Now ③.
③ 1 + 2(2) − 3 = 1 + 4 − 3 = 2
We get 2, the same as the right side.
All of them work.
So the answer is right!
Let's look back.
First: write the augmented matrix.
Then: get 0s under the 1 in column 1.
Then: get a 1 in row 2.
Then: get 0s under the 1 in column 2.
Then: get a 1 in row 3.
Then: back substitution.
Last: check.
Answer (x, y, z) = (1, 2, 3)
▶ Watch it solved
The question
Question: solve 2x + y + z = 7, x + y + z = 6 and x − y + 2z = 5 by Gaussian elimination.
2x + y + z = 7①
x + y + z = 6②
We want the x, y and z that make all three true.
x − y + 2z = 5③
We will use three moves on the rows.
Swap two rows.
Times a row by a number that is not 0.
Add a multiple of one row to another.
Each move keeps the equations true, like in elimination.
swap two rows
× a row by a number (not 0)
add a multiple of one row to another
1 Write the augmented matrix
Each row is one equation: the numbers in front of x, y and z, then the number on the right.
The bar stands for the = signs.
This is called an augmented matrix.
= [2, 1, 1, 7; 1, 1, 1, 6; 1, −1, 2, 5]
We call the rows R 1, R 2 and R 3.
Our goal: 1s down the diagonal, and 0s under them.
This shape is called row-echelon form.
Then we go back up, one letter at a time.
goal: 1s down the diagonal, 0s under them
2 Get a 1 in row 1
→ [1, 1, 1, 6; 2, 1, 1, 7; 1, −1, 2, 5]
3 Get 0s under the 1 in column 1
→ [1, 1, 1, 6; 0, −1, −1, −5; 0, −2, 1, −1]
Careful!
A row move works on the whole row, the number after the bar too.
That number is the right side of the equation.
Careful: the whole row, after the bar too
4 Get a 1 in row 2
→ [1, 1, 1, 6; 0, 1, 1, 5; 0, −2, 1, −1]
5 Get 0s under the 1 in column 2
→ [1, 1, 1, 6; 0, 1, 1, 5; 0, 0, 3, 9]
6 Get a 1 in row 3
→ [1, 1, 1, 6; 0, 1, 1, 5; 0, 0, 1, 3]
7 Back substitution
Start at the bottom.
Each row is an equation again.
Row 3 is 1z = 3, with 0 for the other letters.
So z = 3.
z = 3
Row 2 is the equation y + z = 5.
y + z = 5
We know z = 3.
We put it in.
y + 3 = 5
Work it out: y + 3 = 5.
y + 3 = 5
To remove the + 3, we take away 3 on both sides.
y + 3 − 3 = 5 − 3
So y = 2.
y = 2
Row 1 is the equation x + y + z = 6.
x + y + z = 6
We know y = 2 and z = 3.
We put them in.
x + 2 + 3 = 6
Work it out: x + 5 = 6.
x + 5 = 6
To remove the + 5, we take away 5 on both sides.
x + 5 − 5 = 6 − 5
So x = 1.
x = 1
We write it as (1, 2, 3).
(x, y, z) = (1, 2, 3)
8 Check
Let's check in every equation.
We put x = 1, y = 2, z = 3 into ①.
① 2(1) + 2 + 3 = 2 + 2 + 3 = 7
We get 7, the same as the right side.
Now ②.
② 1 + 2 + 3 = 6
We get 6, the same as the right side.
Now ③.
③ 1 − 2 + 2(3) = 1 − 2 + 6 = 5
We get 5, the same as the right side.
All of them work.
So the answer is right!
Let's look back.
First: write the augmented matrix.
Then: get a 1 in row 1.
Then: get 0s under the 1 in column 1.
Then: get a 1 in row 2.
Then: get 0s under the 1 in column 2.
Then: get a 1 in row 3.
Then: back substitution.
Last: check.
Answer (x, y, z) = (1, 2, 3)
▶ Watch it solved