Skip to content

Partial pivoting in Gaussian elimination

5 min read

Short answer

Before eliminating a column, swap rows so the largest-magnitude entry in that column becomes the pivot. This keeps all multipliers at most 11 in size, so rounding errors are not amplified. Without it, a tiny pivot can produce a completely wrong answer even for a well-conditioned system.

No pivoting compared with Partial pivotingNo pivotingPivot 0.0001 givesmultiplier 10 000Rounding errors blowupWrong x₁ = 0Partial pivotingSwap rows: pivot 1Multiplier 0.0001Correct x₁ ≈ 1
The same equations, two outcomes, in 3-digit arithmetic.

What goes wrong

Eliminating with pivot ε≈10−4\varepsilon\approx10^{-4} needs a multiplier 1/ε=1041/\varepsilon=10^4. The next row then contains numbers like 1−1041-10^4, in which the original 11 is lost to rounding.

Cost and variants

Partial pivoting costs only O(n2)O(n^2) comparisons in total. Complete pivoting searches the whole remaining submatrix and is slightly more stable but rarely needed. Production codes use partial pivoting.

Worked example

Solve (0.0001111)x=(12)\begin{pmatrix}0.0001&1\\1&1\end{pmatrix}\mathbf x=\begin{pmatrix}1\\2\end{pmatrix} keeping 3 significant digits. The exact solution is about (1.0001, 0.9999)(1.0001,\,0.9999).

Without pivoting: multiplier 10410^4; row 2 becomes −9999→−1.00×104-9999\to-1.00\times10^4 and rhs −9998→−1.00×104-9998\to-1.00\times10^4, so x2=1.00x_2=1.00 and x1=(1−1.00)/0.0001=0x_1=(1-1.00)/0.0001=0. Wrong. With a swap: multiplier 10−410^{-4}; row 2 becomes 0.9999→1.000.9999\to1.00 and rhs 0.9998→1.000.9998\to1.00, so x2=1.00x_2=1.00 and x1=2−1=1.00x_1=2-1=1.00. Correct.

Try it yourself

Which row should you swap to the top for the first column (0.2, 5, −8)T(0.2,\,5,\,-8)^T?

Show the answer

The row with −8-8 (largest absolute value), so all multipliers are at most 11 in magnitude.

Keep going with practice

Vidi's linear algebra lessons practise row operations; here you see why their order matters on a computer.