skip to contentstylized crane logoWhite Crane Education

Section 1.2 - Partial Pivoting

When we work through examples of Gaussian elimination in math classes, we usually choose "nice numbers" like small integers, simple fractions, and decimals with only a few digits that make the calculations easy. Real-world problems are rarely so convenient. When Gaussian elimination is done with data from an experiment, a physical model or another computational process, the entries in a system of equations can contain many digits and may not have simple exact representations.

This creates an important difference between doing mathematics by hand and doing the same calculations on a computer. In exact mathematics, we can treat numbers like 1/3 as exact quantities. A computer, on the other hand, can't store an infinitely long decimal expansion. The number $1/3 = 0.3333...$, for example, has to be represented using a finite number of digits, so the stored value is necessarily an approximation. This can become an issue with operations like Gaussian elimination that involve a large number of arithmetic operations where a small amount of rounding error at the beginning of a process can get magnified significantly by the time it's finished.

Consider this example:

$$0.003x+46y = 46.49 \\ 7.65x-5y = 71.45$$

You can confirm for yourself that $(10, 1.01)$ is the exact solution. Now assume instead that we're doing this on a computer whose operating system only holds four significant digits. If we go through the Gaussian Elimination process, multiplying the first row by 2550 and subtracting that from the second row, gives us

$$\begin{bmatrix} 0.003&46&46.49 \\ 0&-117300&-118400\end{bmatrix}$$

Using back substitution and rounding the result of every arithmetic operation to four digits gives us $y=1.009$, which has some round off error but isn't bad, and $y=26.67$ which is significantly incorrect.

So what went wrong? If you're interested in all the details, you should check out our numerical analysis class where we have a whole chapter that discusses linear algebra related computations including this one. The short answer is that, to get the multiplier, we had to divide by a relatively small number (0.003) which gave us a large multipler (2550). When we multiplied that by other large numbers like 71.45 and rounded the result, we lost a lot of accuracy. The solution to this is a method called "partial pivoting".

Partial Pivoting

In the previous example, the problem was caused when we divided by a really small number so our solution is going to be to use the first elementary row operation (the one that says we can switch two rows in the augmented matrix) to make sure that the pivot value is always as large as possible. The process goes like this:

  1. Identify the current pivot value.
  2. Look at all the values below the pivot value in the pivot column looking for the largest one.
  3. Switch the current row with the row that had the largest value

Looking back at our example, the second row has the largest value in the first column so our procedure says to switch it with the first row making the matrix:

$$\begin{bmatrix} 7.65 & -5 & 71.45 \\ 0.003&46&46.490\end{bmatrix}$$

Now we would multiply the first row by $0.003/7.65 = 0.0003922$ and add it to the second giving us:

$$\begin{bmatrix} 7.65 & -5 & 71.45 \\ 0&46&46.46\end{bmatrix}$$

Working through the back substitutiong gives $y = 1.01$ and $x=10$ which exactly matches the exact result.


link to Facebook