We need a systematic way to solve a system of linear equations when there are too many variables to find by guessing and plugging in.
Suppose we want to find the values of x,y, and z that make all three of these equations true at the same time:
x+2y+z2x+5y+3zx+4y+4z=8=21=21
Instead of jumping straight into algebra, let's look at the staircase shape we wish this system had and the three legal moves that let us reshape equations without changing their solution.
The Staircase System and the Three Legal Moves
x2xx+++2y5y4y+++z3z4z===82121
x=?y=?z=?
original systemx+2y+z2x+5y+3zx+4y+4z=8=21=21⟶staircase systemx+2y+zy+zz=8=5=3
Once a system is in staircase form, the bottom equation gives z=3 right away, and plugging upwards gives y+3=5⟹y=2 and x+2(2)+3=8⟹x=1.
1
Building the Staircase in an Augmented Matrix
Now we want to turn our original system into that staircase using the three legal moves, without rewriting x,y,z, and = at every step.
Building the Staircase in an Augmented Matrix
Text solution
Write the numbers in an augmented matrixKeep only the coefficients and right-hand numbers in a grid, with a vertical line for the equals signs.
Clear Column 1 below the first pivotCircle the top-left pivot 1 in Row 1, subtract twice Row 1 from Row 2 (R2←R2−2R1), and subtract Row 1 from Row 3 (R3←R3−R1) so every entry below the first pivot becomes 0.
Step diagonally down to the Row 2 pivot and clear Column 2Move to the pivot 1 in Row 2, Column 2 and subtract twice Row 2 from Row 3 (R3←R3−2R2) to finish the triangle of zeros in the bottom-left corner.
1002121138513R3←R3−2R2Row Echelon Form (staircase)100210111853
Putting x,y, and z back into the rows gives the staircase system x+2y+z=8,y+z=5, and z=3, so z=3,y=2, and x=1.
Once Column 1 is cleared in 1002121138513, see what happens to our zero in Row 3, Column 1 if we try to cancel the 2 in Column 2 using Row 1 instead of Row 2.
Either row above can cancel the 2 in the third row, but only the second row has a zero in the first column to leave your earlier work untouched.
2
Clearing Above the Pivots
Once we reach the staircase, we can either plug numbers back into the equations from the bottom up (back-substitution) or stay inside the matrix and use the pivots to clear the numbers above them too.
Clearing Above the Pivots
Text solution
Clear Column 3 above the bottom-right pivotStarting at the pivot 1 in Row 3, Column 3, subtract Row 3 from Row 2 (R2←R2−R3) and from Row 1 (R1←R1−R3).
Putting the variables back into the rows gives 1x=1,1y=2, and 1z=3, so x=1,y=2, and z=3 without any back-substitution.
3
Pivots That Aren't 1, Negative Numbers, and Fractions
In the first system, every pivot happened to be 1. Now let's solve a system where the pivots are other integers or fractions and negative numbers show up:
2x+y−z3x+2y+z−4x+y+2z=1=10=4
Pivots That Aren't 1, Negative Numbers, and Fractions
To eliminate any entry below a pivot, divide the entry you want to cancel by the pivot itself:
Multiplier=PivotEntry to eliminate(because Pivot×PivotEntry=Entry)
Text solution
Clear Column 1 using pivot 2For Row 2, the multiplier is 23, so subtract 23R1 from Row 2; for Row 3, the multiplier is 2−4=−2, and subtracting −2R1 is the same as adding 2R1.
Divide each row by its pivot to make every pivot 1Divide Row 3 by −15, Row 2 by 21 (which multiplies Row 2 by 2 and clears its fractions), and Row 1 by 2.
Clear above the pivots from the bottom upUse the Row 3 pivot to clear Column 3 (R2←R2−5R3 and R1←R1+21R3), then use the Row 2 pivot to clear Column 2 (R1←R1−21R2).
Reading across the rows gives the solution x=1,y=2, and z=3. You don't have to save dividing by the pivots until the end: if a row like [0,21,25217] has fractions, you can multiply that row by 2 right before using it as a pivot so you only work with whole numbers.
4
Zero in the Pivot Spot, No Solution, and Free Variables
The rule Multiplier=PivotEntry works for any pivot except 0, because dividing by 0 is undefined: multiplying 0 by any number still gives 0 and cannot cancel a non-zero entry below it. Here is how to fix a 0 in the pivot spot, and what it means when no non-zero number is available below it and an entire row of variables cancels out.
Zero in the Pivot Spot, No Solution, and Free Variables
A non-zero entry sits below the 0 pivot: Swap rows: Swap the row with the 0 pivot and a row below it that has a non-zero number in that column.
100202131895R2↔R3100220113859
The bottom row becomes [000∣non-zero]: No Solution: Put the variables back in to read what the bottom row says.
[0005]⟶0x+0y+0z=5⟹never true (No Solution)0=5
The bottom row becomes [000∣0]: Free Variable and Infinitely Many Solutions: A row of all zeros means 0=0, so that equation adds no new information and leaves a column without a pivot.
1000102−10430⟶⎩⎨⎧Columns 1 and 2 have pivots (x and y are determined by z)Column 3 has no pivot (free variablez⟹Infinitely Many Solutions)
When a 0 lands in the Row 2, Column 2 pivot spot, what happens next depends entirely on the third row.
A zero in a pivot spot is fixed by swapping when a non-zero number sits below it, while all zeros below it clear the bottom row into either a true statement or an impossible one.
5
Gaussian Elimination from Start to Finish
Now let's put all the steps together from the starting equations to the final answer.
Gaussian Elimination from Start to Finish
Key concepts
Building the staircase (Row Echelon Form)
Write the system as an augmented matrix and work column by column from left to right, stepping diagonally down from one pivot to the next so the zeros to the left of each new pivot keep the columns you already cleared at zero. To cancel an entry below a pivot, subtract Multiplier×(Pivot Row) using
Multiplier=PivotEntry to eliminate
For example, to eliminate −4 below a pivot of 2, the multiplier is 2−4=−2, so you subtract −2R1, which adds 2R1 (R3←R3+2R1).
When a 0 lands in the pivot spot
Do not use PivotEntry. Look below the 0 in that same column: if there is a non-zero entry below it (like a 2 in Row 3 beneath a 0 in Row 2), swap those two rows (R2↔R3) and keep going.
Two ways to finish from the staircase
If you just want the values of x,y, and z quickly, stop as soon as you have the staircase (Row Echelon Form) and use back-substitution from the bottom equation up (z=3⟹y+3=5⟹x+2(2)+3=8). Only divide each row by its pivot and clear above the pivots from the bottom-right pivot upwards (Gauss-Jordan elimination) when you want the matrix in Reduced Row Echelon Form100010001xyz.
When a row of variables cancels out
Write the bottom row back as an equation. A row like [000∣5] means 0=5, so there is No Solution. A row of all zeros [000∣0] means 0=0, which adds no new information and leaves a column without a circled pivot. That column's variable is a free variable, so the system has Infinitely Many Solutions.
6
Practice
1
Write the augmented matrix for the system x+y+z=7,2x+3y+3z=19,x+3y+4z=21, eliminate below the pivots to reach a staircase (Row Echelon Form), and solve by back-substitution.
Once Column 1 is cleared below the top-left 1, which row's pivot has a 0 in Column 1 that keeps your zeros unchanged when you eliminate the 2 in Row 3, Column 2?
Write the system as an augmented matrix and clear Column 1 using the pivot 1 in Row 1:
(Watch out: remember to multiply the right-hand side of Row 2 by 2 as well, doing 14−2(5)=4; forgetting to double the 5 gives 14−5=9, which leads to the wrong answer z=9,y=−4,x=2.)
Back-substituting from the bottom row up:
zy+4x+1+4=4=5⟹y=1=7⟹x=2
2
This augmented matrix is already in staircase form:
200210−23−428−8
Divide each row by its pivot so every pivot is 1, then clear above the pivots (Gauss-Jordan elimination) to reach Reduced Row Echelon Form and read off x,y, and z.
Watch out: to cancel the −1 in Row 1, Column 3, you must add R3 (R1←R1+R3, giving 1+2=3 on the right); subtracting R3 by mistake gives 1−2=−1 on the right and leads to x=−3.
After dividing Row 3 by −4 and Row 1 by 2, start at the bottom-right pivot and work upwards so the zeros to its left keep Columns 1 and 2 unchanged.
Divide Row 3 by −4 and Row 1 by 2 so all three pivots are 1:
(Watch out: to cancel the −1 in Row 1, Column 3, you must add R3 (R1←R1+R3, giving 1+2=3 on the right); subtracting R3 by mistake gives 1−2=−1 on the right and leads to x=−3.)
x=1,y=2,z=2
3
Solve the system 2x+y+z=6,3x+2y+2z=10,−2x+2y+3z=3 using Multiplier=PivotEntry.
Watch out: dividing 3 by 21 gives 6, not 23; also, when back-substituting z=3 into Row 2, 21y+23=1 gives 21y=−21⟹y=−1, whereas adding 1+23=25 gives the wrong answer y=5,x=−1.
After clearing Column 1 with multipliers 23 and 2−2=−1, your Row 2 pivot is 21. What do you get when you divide the entry 3 below it by 21?
Write the augmented matrix and clear Column 1 using the pivot 2 in Row 1 (multiplier 23 for Row 2 and 2−2=−1 for Row 3):
Watch out: Row 1 has −1 in Column 3, so subtracting 2(−1) in Row 2 gives 1−(−2)=3 and subtracting −1 in Row 3 gives 2−(−1)=3; dropping the negative sign gives −1 and 1 in Column 3, which leads to the wrong answer z=−3,y=7,x=−14.
Write the augmented matrix and clear Column 1 first. What lands in the Row 2, Column 2 pivot spot, and which legal move puts a non-zero pivot there?
(Watch out: Row 1 has −1 in Column 3, so subtracting 2(−1) in Row 2 gives 1−(−2)=3 and subtracting −1 in Row 3 gives 2−(−1)=3; dropping the negative sign gives −1 and 1 in Column 3, which leads to the wrong answer z=−3,y=7,x=−14.)
A 0 landed in the Row 2, Column 2 pivot spot with a 1 below it in Row 3, so swap Row 2 and Row 3:
R2↔R3100201−133334100210−133343
Back-substituting from the bottom row up:
3zy+3(1)x+2(1)−1=3⟹z=1=4⟹y=1=3⟹x=2
5
Use Gaussian elimination to determine whether the system x+y+2z=4,2x+3y+5z=11,3x+4y+7z=10 has a unique solution, no solution, or infinitely many solutions.
Clear Column 1, then use the Row 2 pivot to clear Column 2 and write the entire bottom row, including the right-hand side, back as an equation.
Clear Column 1 using the pivot 1 in Row 1, then clear Column 2 using the pivot 1 in Row 2:
(Watch out: don't stop at the three zeros on the left of the bottom row and call it "Infinitely Many Solutions". Check the number to the right of the line, which is −5, not 0.)
The bottom row means 0x+0y+0z=−5, or 0=−5, which is never true:
No Solution
6
Finish eliminating the augmented matrix
100−12−22−4456−6
How many solutions does the system have, and which variable is free?
Use the pivot 2 in Row 2, Column 2 to eliminate the −2 below it, then circle your pivots and check which column is missing one.
Using the pivot 2 in Row 2, Column 2, the multiplier for Row 3 is 2−2=−1, so add Row 2 to Row 3 (R3←R3+R2):
The bottom row means 0=0, so the third equation adds no new information. Columns 1 and 2 have pivots (1 and 2) that determine x and y once z is chosen, while Column 3 has no pivot. (Watch out: 0=0 is always true, not a false statement like 0=−6, and the free variable belongs to the column without a pivot: Column 3 (z), not x or y.)
Infinitely Many Solutions, with z as the free variable