Skip to content

Pivoting

Gaussian elimination computes a multiplier mik=aik/akkm_{ik} = a_{ik} / a_{kk} at every step, where akka_{kk} 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=0a_{11} = 0:

0x1+2x2+x3=40x_{1}+2x_{2}+x_{3}=4

x1−2x2+2x3=2x_{1}-2x_{2}+2x_{3}=2

2x1+12x2−2x3=42x_{1}+12x_{2}-2x_{3}=4

In matrix form:

[0211−22212−2][x1x2x3]=[424]\begin{bmatrix}0&2&1\\1&-2&2\\2&12&-2\end{bmatrix}\begin{bmatrix}x_{1}\\x_{2}\\x_{3}\end{bmatrix}=\begin{bmatrix}4\\2\\4\end{bmatrix}

Since a11=0a_{11} = 0, computing m21=a21/a11m_{21} = a_{21}/a_{11} 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 xx stay in exactly the same order, but the right-hand side constants bb must be swapped along with their corresponding rows.

Step-by-step

Starting from the augmented matrix:

[02141−222212−24]\left[\begin{array}{ccc|c}0&2&1&4\\1&-2&2&2\\2&12&-2&4\end{array}\right]

The pivot position a11=0a_{11} = 0. Looking down column 1, Row 2 has a21=1≠0a_{21} = 1 \ne 0. Swap Row 1 and Row 2.

Apply R1↔R2R_1 \leftrightarrow R_2:

[1−2220214212−24]\left[\begin{array}{ccc|c}1&-2&2&2\\0&2&1&4\\2&12&-2&4\end{array}\right]

The resulting system is:

[1−22021212−2][x1x2x3]=[244]\begin{bmatrix}1&-2&2\\0&2&1\\2&12&-2\end{bmatrix}\begin{bmatrix}x_{1}\\x_{2}\\x_{3}\end{bmatrix}=\begin{bmatrix}2\\4\\4\end{bmatrix}

The new pivot is a11=1≠0a_{11} = 1 \ne 0. Gaussian elimination can now proceed normally. Notice that the constants vector changed from [424]\begin{bmatrix}4\\2\\4\end{bmatrix} to [244]\begin{bmatrix}2\\4\\4\end{bmatrix} — the swap affected bb but left the variable order in xx 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 bb remains unchanged, but the variable vector xx 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:

[0211−22212−2][x1x2x3]=[424]\begin{bmatrix}0&2&1\\1&-2&2\\2&12&-2\end{bmatrix}\begin{bmatrix}x_{1}\\x_{2}\\x_{3}\end{bmatrix}=\begin{bmatrix}4\\2\\4\end{bmatrix}

The pivot position a11=0a_{11} = 0. Looking across Row 1, Column 2 has a12=2≠0a_{12} = 2 \ne 0. Swap Column 1 and Column 2 in AA, and simultaneously swap x1x_1 and x2x_2 in xx.

Apply C1↔C2C_1 \leftrightarrow C_2 to AA and x1↔x2x_1 \leftrightarrow x_2 to xx:

[201−212122−2][x2x1x3]=[424]\begin{bmatrix}2&0&1\\-2&1&2\\12&2&-2\end{bmatrix}\begin{bmatrix}x_{2}\\x_{1}\\x_{3}\end{bmatrix}=\begin{bmatrix}4\\2\\4\end{bmatrix}

The new pivot is a11=2≠0a_{11} = 2 \ne 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 x2x_2, and the second to x1x_1. The values must be unswapped before stating the final answer.