Worked examples — Solving linear systems — Gaussian elimination with partial pivoting
Before anything, three words you must own (each built in the parent, repeated here so line one stands alone):
- Pivot — the number sitting on the diagonal that we divide by. Picture the top-left corner of the block we are currently clearing.
- Multiplier — how many copies of the pivot row we subtract from row to punch a zero into position .
- Augmented matrix — the coefficient grid with the right-hand side stapled on as one extra column, so every row operation touches the answer column too.
The scenario matrix
Every linear-system problem this topic throws lands in exactly one of these cells. Our job below is to hit all of them.
| Cell | What makes it special | Danger it probes | Hit by |
|---|---|---|---|
| C1 Clean unique | biggest pivot already on top, nice numbers | none — the baseline | Ex 1 |
| C2 Swap needed | biggest entry is below the diagonal | forgetting to pivot | Ex 2 |
| C3 Tiny pivot | a near-zero would-be pivot | round-off blow-up | Ex 3 |
| C4 Negative pivots & signs | negative diagonal, negative multipliers | sign slips in | Ex 4 |
| C5 Zero pivot, but fixable | a literal on the diagonal that a swap rescues | "divide by zero" panic | Ex 5 |
| C6 Singular — no solution | whole row collapses to , | recognising failure | Ex 6 |
| C6′ Singular — infinitely many | whole row collapses to | free variables | Ex 6′ |
| C7 Word problem (real units) | mixture / circuit modelled as | translating words → matrix | Ex 7 |
| C8 Exam twist (parameter) | an unknown decides solvability | limiting behaviour | Ex 8 |
Ex 1 — Cell C1: the clean baseline
Forecast: column 1 has , so no swap. Guess the answer is small positive numbers.
- Check the pivot. Why this step? Partial pivoting first looks at column 1, rows 1–2: vs . The biggest is already on top, so no swap.
- Multiplier. Why this step? We need a in position . .
- Eliminate. Why this step? Subtracting row 1 kills and updates the rest of the row (including the RHS):
- Back-substitute. Why bottom-up? The last row now has one unknown:
Verify: eq 2: .
Ex 2 — Cell C2: a swap is forced
Forecast: down column 1, so we must swap. Guess: swapping first, then a clean elimination.
- Scan column 1. Why this step? Among rows 1–2, ; the biggest sits in row 2. Swap rows 1 and 2 — the entire rows, RHS included.
- Multiplier. Why this step? Now the pivot is a safe . .
- Eliminate. Why: punch the zero and update:
- Back-substitute. Why bottom-up? The eliminated row 2 now holds only , so we solve it first, then feed that value up into row 1:
Verify: eq 1 (original): ; eq 2: .

The figure shows why pivoting is a geometric idea: each equation is a line, the solution is their crossing point, and swapping rows never moves that crossing — it just relabels which line we clear first.
Ex 3 — Cell C3: the tiny-pivot trap (with vs without)
Forecast: the exact answer (solving the two equations) is . Guess the no-pivot route corrupts .
Route A — WITHOUT pivoting (the cautionary tale).
- Keep the tiny pivot . Why show this? To expose the failure the parent warned about. . A monster multiplier magnifies every rounding error.
- Round each result to 4 sig figs. Why: our imaginary calculator only holds 4 digits.
- . Then . Why it breaks: , and — a subtraction of near-equal 4-digit numbers keeps only one good digit. So , badly wrong (true value ).
Route B — WITH pivoting.
- Swap first. Why this step? Partial pivoting scans column 1, rows 1–2: , so the biggest goes on top. This is the whole point — never divide by the tiny entry.
- Multiplier. Why: to zero the entry. (tiny magnitude ⇒ tiny error amplification).
- Eliminate, rounding to 4 sig figs. ; .
- Back-substitute. Why bottom-up: row 2 now has one unknown. ; .
Verify: the exact solution has . Numerically, eq 1 with : . Pivoting kept ; no-pivoting destroyed it. See Round-off Error in Floating Point and Condition Number and Numerical Stability.
Ex 4 — Cell C4: negative pivots and negative multipliers
Forecast: , so no swap; the pivot is negative — watch the signs.
- Scan. Why: , biggest already on top. No swap. The pivot is ; negative is fine — only small magnitude is bad.
- Multiplier. . Why the minus matters: subtracting a negative multiple means we effectively add. Keep the sign attached.
- Eliminate. RowRowRow:
- Back-substitute.
Verify: eq 2: .
Ex 5 — Cell C5: a literal zero pivot that a swap rescues
Forecast: — you cannot divide by it. But there is a nonzero entry below, so a swap saves us. Pivoting handles this automatically.
- Scan column 1. Why this step? Rows 1–2 give vs . Largest is in row 2 — swap. The rule that always picks the biggest magnitude never leaves a on the diagonal when a nonzero exists below.
- Lucky elimination. : row 2 is already clear. Why: the swap did all the work.
- Back-substitute.
Verify: original eq 1: ; eq 2: .
Ex 6 — Cell C6: genuinely singular (no solution)
Forecast: row 2 is almost half of row 1 — the left sides are proportional but the right sides are not. Guess: no solution (parallel lines).
- Scan / no swap. , pivot .
- Eliminate. :
- Read the bottom row. Why this step? The last row says , i.e. — impossible. The whole column-2 sub-block collapsed to zero, so there is no pivot and the RHS is nonzero ⇒ no solution at all.
Verify: , confirming singularity — see Determinants and why Cramer's Rule also fails here (it divides by ).

The two lines are parallel and distinct — they never cross, which is the geometric face of "".
Ex 6′ — Cell C6′: singular with infinitely many solutions
Forecast: now row 2 is exactly half of row 1 — same line twice. Guess: infinitely many solutions along one line.
- Scan / no swap. Why: down column 1, pivot already on top.
- Eliminate. Why this step? Punch the zero in . :
- Read the bottom row. Why this step? It now says — always true, no information. So is a free variable: pick any value .
- Back-substitute with the free variable. Why: row 1 still constrains in terms of . From : Infinitely many solutions, one for each .
Verify: pick : gives and . Pick : gives and . Both lie on the single shared line.
Ex 7 — Cell C7: a real word problem (mixtures, with units)
Forecast: total volume 10 L, so guess A is the larger share (32% is closer to 20%).
- Translate to a system. Why this step? Let = litres of A, = litres of B. Volume balance and acid balance give
- Pivot check. Why this step? Scan column 1, rows 1–2: , so the biggest is already on top — no swap, pivot .
- Eliminate. Why this step? We want a in position so row 2 holds only one unknown. ; then , .
- Back-substitute. Why bottom-up: row 2 now has just .
Verify (units + acid): total L . Acid: L, and . As forecast, A is the larger share.
Ex 8 — Cell C8: exam twist with a parameter (limiting behaviour)
Forecast: a zero pivot will appear after elimination for one special . Guess .
- Pivot honestly — a swap is forced. Why this step? Scan column 1, rows 1–2: for every (column 1 does not contain ). Partial pivoting therefore swaps rows 1 and 2 before doing anything — we must not assume a pivot of .
- Eliminate symbolically. Why this step? Punch a in ; the resulting entry tells us when the method stalls. Pivot , so :
- Find the failure. Why this step? Back-substitution divides by . This is zero when , i.e. . Then the bottom row reads ⇒ no unique solution. This is the limiting value of the parameter (and indeed vanishes there too).
- Solve for . Why this step? Plug the concrete value into the eliminated system so both unknowns follow. Here :
Verify: at , original eq 2: ; eq 1: . At , — singular exactly as predicted.
Recall The whole matrix in one breath
Baseline (C1) ::: biggest pivot already on top, just eliminate and climb back. Forced swap (C2) ::: biggest entry is below — swap whole rows first. Tiny pivot (C3) ::: pivoting avoids a monster multiplier that would wreck round-off. Negative pivot (C4) ::: negative is fine; only small magnitude is the enemy — keep the multiplier's sign. Zero pivot, fixable (C5) ::: a nonzero below rescues you; pivoting does it automatically. Singular, no solution (C6) ::: last row becomes with (). Singular, infinitely many (C6′) ::: last row becomes ⇒ free variable. Word problem (C7) ::: name the unknowns, write one equation per balance law, then solve. Parameter twist (C8) ::: after the forced swap the pivot-2 entry is ; it vanishes at .
See also LU Decomposition (elimination remembered as a factorisation), Back-substitution and Forward-substitution, and Iterative Methods (Jacobi, Gauss-Seidel) for when is huge.