Gaussian elimination computes a multiplier mik=aik/akk at every step, where akk is the diagonal entry used to eliminate the column below it. This diagonal entry is called the pivot. If the pivot is exactly zero, the formula produces a division by zero and the algorithm fails. Pivoting is the strategy of rearranging the matrix before each elimination step to ensure a non-zero (and preferably large) element sits in the pivot position.
The Problem: A Zero Pivot
Consider the system below, where a11=0:
0x1+2x2+x3=4
x1−2x2+2x3=2
2x1+12x2−2x3=4
In matrix form:
0122−21212−2x1x2x3=424
Since a11=0, computing m21=a21/a11 would require dividing by zero. We must rearrange the matrix before proceeding. There are two ways to do this.
Case 1: Partial Pivoting (Row Swapping)
Partial pivoting fixes a zero pivot by scanning down the current column and swapping the offending row with any row below it that has a non-zero entry in that column position.
Key rule: Swapping two rows simply changes the order of the equations. The variables x stay in exactly the same order, but the right-hand side constants b must be swapped along with their corresponding rows.
Step-by-step
Starting from the augmented matrix:
0122−21212−2424
The pivot position a11=0. Looking down column 1, Row 2 has a21=1=0. Swap Row 1 and Row 2.
Apply R1↔R2:
102−221221−2244
The resulting system is:
102−221221−2x1x2x3=244
The new pivot is a11=1=0. Gaussian elimination can now proceed normally. Notice that the constants vector changed from 424 to 244 — the swap affected b but left the variable order in x untouched.
Case 2: Complete Pivoting (Column Swapping)
Complete pivoting fixes a zero pivot by scanning across the current row and swapping the offending column with any column to its right that has a non-zero entry in that row position.
Key rule: Swapping two columns changes the order of the variables. The right-hand side b remains unchanged, but the variable vector x must have its corresponding entries swapped to reflect the new column ordering. At the end of the solve, the variables must be swapped back to report the answer in the original order.
Step-by-step
Starting from the original system:
0122−21212−2x1x2x3=424
The pivot position a11=0. Looking across Row 1, Column 2 has a12=2=0. Swap Column 1 and Column 2 in A, and simultaneously swap x1 and x2 in x.
Apply C1↔C2 to A and x1↔x2 to x:
2−21201212−2x2x1x3=424
The new pivot is a11=2=0. Gaussian elimination can now proceed.
Important: After completing the elimination and back substitution on this reordered system, the first component of the solution vector will correspond to x2, and the second to x1. The values must be unswapped before stating the final answer.