Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

 Open In Colab

The Need for Pivoting

The order of equations (and therefore rows in the matrix) is mathematically arbitrary, but the physical order in memory can break Gaussian Elimination.

For example, a system with the following augmented matrix works perfectly with our standard GE algorithm:

[2−101−12−100−110]\begin{bmatrix} 2 & -1 & 0 & 1\\ -1 & 2 & -1 & 0\\ 0 & -1 & 1 & 0 \end{bmatrix}

But the exact same system, simply reordered, will fail:

[0−110−12−102−101]\begin{bmatrix} 0 & -1 & 1 & 0\\ -1 & 2 & -1 & 0\\ 2 & -1 & 0 & 1 \end{bmatrix}

Because the pivot element in the first row is 0, calculating the multiplier m2,1=−1/0m_{2,1} = -1 / 0 results in a division by zero!

The remedy is to pivot (swap) row 1 with another row to put a non-zero element on the diagonal.

The Permutation Matrix

Swapping rows in matrix algebra is achieved via a permutation matrix P\mathbf{P} (which is simply a row-swapped identity matrix I\mathbf{I}).

To mathematically swap rows 3 and 1 of a matrix, we multiply it by:

P=[001010100]\mathbf{P} = \begin{bmatrix} 0 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 0 \end{bmatrix}

Roundoff Error and Small Pivots

Even if the pivot isn’t exactly 0, a very small pivot element causes catastrophic roundoff error.

Consider a matrix where the top-left element is some incredibly small number ϵ\epsilon:

[ϵ−110−12−102−101]\begin{bmatrix} \epsilon & -1 & 1 & 0\\ -1 & 2 & -1 & 0\\ 2 & -1 & 0 & 1 \end{bmatrix}

After the first pass of Gaussian Elimination, the matrix becomes:

[ϵ−110−12−1/ϵ−1+1/ϵ02−1−1/ϵ1/ϵ1]\begin{bmatrix} \epsilon & -1 & 1 & 0\\ -1 & 2 - 1/\epsilon & -1 + 1/\epsilon & 0\\ 2 & -1 - 1/\epsilon & 1/\epsilon & 1 \end{bmatrix}

We can immediately see the danger as ϵ→0\epsilon \rightarrow 0. The terms 1/ϵ1/\epsilon become infinitely massive, completely dominating and erasing the true values of the other coefficients due to floating-point truncation (roundoff error).

This motivates our desire to have the largest possible numbers on the diagonal!

Diagonal Dominance

A matrix is said to be diagonally dominant if the absolute value of each diagonal element is strictly larger than the sum of the absolute values of the other elements in that row.

∣Aii∣≥∑j=1,j≠in∣Aij∣|A_{ii}| \ge \sum_{j=1,j \ne i}^{n} |A_{ij}|

Which of these is diagonally dominant?

A) $$

[−24−1−1−134−21]\begin{bmatrix} -2 & 4 & -1 \\ -1 & -1 & 3 \\ 4 & -2 & 1 \end{bmatrix}

$$

B) $$

[4−21−24−1−1−13]\begin{bmatrix} 4 & -2 & 1 \\ -2 & 4 & -1 \\ -1 & -1 & 3 \end{bmatrix}

$$

(Answer: Matrix B is diagonally dominant! Notice how Matrix A is just Matrix B without row-pivoting. By swapping the rows of A, we can achieve diagonal dominance!)

The Importance of Diagonal Dominance

It can be mathematically proven that if a matrix is diagonally dominant, it will never require pivoting during Gaussian Elimination, and it is inherently immune to the catastrophic ϵ→0\epsilon \rightarrow 0 roundoff errors shown above.

Diagonal dominance contributes broadly to numerical stability. It is a critical criteria for matrix factorization methods and ensures the rapid convergence of iterative methods!