Linear Algebra, Live
Strang §2.2 · Pivots

Pivots and back substitution: clear the columns, then solve from the bottom up

Slide 2 removed one unknown from two equations. With three equations and three unknowns we repeat that step in a fixed order: one column at a time, from left to right. The first pivot, the top-left number, clears everything below it in column 1. The second pivot clears column 2. Now the system is a triangle, and the last equation has just one unknown. Solve it, and its value is the key to the equation above, which in turn unlocks the one above that. Climbing back up like this is back substitution.

Lesson 2 · slide 3Pivots
2114−60−272  →  2110−8−2001
Key ideas
  1. Elimination works column by column, from left to right.
  2. Each multiplier uses the current pivot, after the earlier steps.
  3. The result is an upper triangular matrix U: zeros below the diagonal (the entries U₁₁, U₂₂, U₃₃, from top-left to bottom-right). The diagonal entries are the pivots.
  4. Back substitution solves the last row first, then moves up one row at a time.

From two equations to three

Bigger systems need nothing new. We repeat slide 2's step in a fixed order. Take

A = 2114−60−272    with right side b = 5−29

As on slide 2, we work on the augmented matrix [A | b]. Its first row 211|5 means 2x + y + z = 5: numbers in front of x, y and z, then the bar, then the right side. Every step acts on the whole row, bar included. Change only the left side and you get a different system.

ℓᵢⱼ is the multiplier that clears row i, column j.

Column 1

The first pivot is the 2 in the top-left corner. Below it we clear the 4 and the −2:

  • ℓ₂₁ = 4 ÷ 2 = 2. Subtract 2 times row 1 from row 2: 4−60|−2 − 2·211|5 = 0−8−2|−12.
  • ℓ₃₁ = −2 ÷ 2 = −1. Subtract −1 times row 1 from row 3, which means adding row 1: −272|9 + 211|5 = 083|14.

Column 2

Row 2 now starts 0, −8. The second pivot is −8. It clears the 8 below: ℓ₃₂ = 8 ÷ (−8) = −1, so add row 2 to row 3: 083|14 + 0−8−2|−12 = 001|2.

Use the pivot as it is now (−8), not the −6 that sat there at the start. This is the most common mistake by hand.

Circles mark the pivots, and the shaded row is the one that just changed. Column 1 is cleared first, then column 2.

The triangle

U = 2110−8−2001    pivots 2, −8, 1    c = 5−122

The new right side, c, is b after the same steps. Ux = c has the same solution as Ax = b.

U is upper triangular, with the pivots on its diagonal. A pivot can't be zero, because we divide by it. Slide 4 covers what happens when one is.

Back substitution: a chain of keys

The last equation has one unknown. Its value is the key to the equation above, and so on up to the top.

Row 3: z = 2  →  Row 2: −8y − 2·2 = −12, so y = 1  →  Row 1: 2x + 1 + 2 = 5, so x = 1
Back substitution starts at the bottom row, which has one unknown. Each answer goes into the row above.

Computers solve systems with thousands of unknowns in exactly this order: clear column 1, then column 2, and so on, then back substitution from the bottom row up.

Next: Every pivot here was a nonzero number. What if a 0 lands in a pivot position? Slide 4 shows when a row swap fixes it, and when the system has no single answer.

Examples

Example 1 · A full 3 by 3 solve

Solve x + y + z = 3, x + 2y + 2z = 5, x + 2y + 3z = 6.

Show solutionHide solution
ℓ₂₁ = 1: row 2 → (0, 1, 1 | 2).   ℓ₃₁ = 1: row 3 → (0, 1, 2 | 3)
ℓ₃₂ = 1: row 3 → (0, 0, 1 | 1)
z = 1  →  y + 1 = 2, y = 1  →  x + 1 + 1 = 3, x = 1

The pivots are 1, 1, 1.

Example 2 · Back substitution on its own

Solve Ux = c with U = 213012004 and c = 948.

Show solutionHide solution
Row 3: 4z = 8, so z = 2
Row 2: y + 2·2 = 4, so y = 0
Row 1: 2x + 0 + 3·2 = 9, so x = 1.5

Example 3 · Check the answer

Back substitution gave x = 1, y = 1, z = 2. Put them back into the three equations 2x + y + z = 5, 4x − 6y = −2 and −2x + 7y + 2z = 9. Every one must come out right:

Show solutionHide solution
2·1 + 1 + 2 = 5 ✓
4·1 − 6·1 = −2 ✓
−2·1 + 7·1 + 2·2 = 9 ✓

Always check this way. One small slip in elimination shows up here at once.

Example 4

Solve x + 2y + z = 4, 2x + 5y + z = 8, 3x + 7y + 4z = 14.

Show solutionHide solution

ℓ₂₁ = 2: (0, 1, −1 | 0). ℓ₃₁ = 3: (0, 1, 1 | 2). ℓ₃₂ = 1: (0, 0, 2 | 2).

z = 1, then y − 1 = 0 so y = 1, then x + 2 + 1 = 4 so x = 1.

Example 5

Find the pivots of A = 120251013.

Show solutionHide solution

ℓ₂₁ = 2 gives row 2 = 011. ℓ₃₁ = 0, since that entry is already 0. ℓ₃₂ = 1 gives row 3 = 002. The pivots are 1, 1 and 2. None is zero, so elimination works without a row swap.

Exercise Finish the elimination: find ℓ₃₂ so that U is upper triangular. Edit the code and press Run.
slide_3.py Loading Python…
1
Output · Ctrl+Enter runs
Press Run to execute this slide's code. Ctrl+Enter works too.

Enjoying lesson 2? Get the full course: all 8 lessons through the SVD and PCA, your progress saved lesson by lesson, every solution and 5 extra problems per lesson. $20 once, yours for life.

Questions and comments

Stuck on something, or found a mistake? Ask here and I'll answer. You sign in with GitHub.

The full course

From Ax = b to PCA, by running it

Lessons 1 to 3 are free. Finish all eight and you will be able to:

You get: all 8 lessons with Python labs · every worked example and solution · 5 extra problems per lesson · your progress tracked · answers to your questions · every future update.

$20 once · lifetime access
Continue to checkout →

Already a member? Log in to the course