## Gaussian Elimination With Partial Pivoting

Gaussian elimination with partial pivoting is used to solve linear systems of simultaneous equations by reducing the associated matrix of coefficients to upper triangular form with leading term in each row equal to 1, substitute values of variables obtained from the bottom row into the row next from bottom, then these two values into the next from bottom row and so on.
Example:
Consider the system of equations
$x_1+x_2+2x_3=9$

$2x_1+4x_2-3x_3=1$

$3x_1+6x_2-5x_3=0$

Solve the system to 2 decimal places.
The augmented matrix associated with this system is
$\left( \begin{array}{ccc} 1 & 1 & 2 \\ 2 & 4 & -3 \\ 3 & 6 & -5 \end{array} \right| \left| \begin{array}{c} 9 \\ 1 \\ 0 \end{array} \right)$

We need to change the order of the rows so that the largest element by magnitude is in the first row. We do this by interchanging the first and third row.
$\left( \begin{array}{ccc} 3 & 6 & -5 \\ 2 & 4 & -3 \\ 1 & 1 & 2 \end{array} \right| \left| \begin{array}{c} 0 \\ 1 \\ 9 \end{array} \right)$

Divide every element in the first row by 3 so the leading entry is 1.
$\left( \begin{array}{ccc} 1 & 2 & -1.67 \\ 2 & 4 & -3 \\ 1 & 1 & 2 \end{array} \right| \left| \begin{array}{c} 0 \\ 1 \\ 9 \end{array} \right)$

Subtract the twice the first row from the second and subtract the first row from the third row so the first entry in these rows is zero.
$\left( \begin{array}{ccc} 1 & 2 & -1.67 \\ 0 & 0 & 0.34 \\ 0 & -1 & 3.67 \end{array} \right| \left| \begin{array}{c} 0 \\ 1 \\ 9 \end{array} \right)$

Interchange the second and third rows, multiplying the third row by -1.
$\left( \begin{array}{ccc} 1 & 2 & -1.67 \\ 0 & 1 & -3/67 \\ 0 & 0 & 0.34 \end{array} \right| \left| \begin{array}{c} 0 \\ -9 \\ 1 \end{array} \right)$

Divide the third row by 0.34 so the leading term becomes 1.
$\left( \begin{array}{ccc} 1 & 2 & -1.67 \\ 0 & 1 & -3/67 \\ 0 & 0 & 1 \end{array} \right| \left| \begin{array}{c} 0 \\ -9 \\ 2.94 \end{array} \right)$

Then
$x_3=2.94$

$x_2-3,67x_3=-9 \rightarrow x_2=-9+3.67 x_3 = -9 +3.67 \times 2.94 =1.79$

$x_1+2x_2-1.67x_3=0 \rightarrow x_1=-2x_2+1.67x_3 = -2 \times 1.79+1.67 \times 2.94=1.33$

Gaussian elimination with partial pivoting reducing rounding errors in the calculations when all calculations are to a set number of decimal places or significant figures if ccoefficients are large.