 StatLect

# Gauss Jordan elimination algorithm

Gauss Jordan elimination is an algorithm that allows us to transform a linear system into an equivalent system in reduced row echelon form.

The main difference with respect to Gaussian elimination is illustrated by the following diagram. In this lecture we are going to assume that the reader is already familiar with Gaussian elimination and aware of the differences between row echelon form and reduced row echelon form. ## Overview

The aim of the Gauss Jordan elimination algorithm is to transform a linear system of equations in unknowns into an equivalent system (i.e., a system having the same solutions) in reduced row echelon form.

The system can be written as where is the coefficient matrix, is the vector of unknowns and is a constant vector.

Remember that a system is in reduced row echelon form if its coefficient matrix has the following properties:

• all non-zero rows contain an element, called pivot, that is non-zero and has only zero entries below it and to its left;

• all pivots are equal to ;

• a pivot is the only non-zero element of its column;

• zero-rows (if there are any) are below the non-zero rows;

Gauss Jordan elimination consists in a sequence of elementary row operations:

1. interchanging the order of the equations, so as to make sure that the zero rows are at the bottom of the matrix;

2. multiplying (or dividing) the equations by non-zero constants, so as to make the pivots equal to ;

3. adding multiples of some equations to other equations, so as to annihilate the entries above and below the pivots.

## Steps of the algorithm

The Gauss Jordan algorithm is very similar to Gaussian elimination. Therefore, we are not going to explain its steps in detail, but we are only going to comment on the differences with respect to Gaussian elimination. Please refer to the lecture on Gaussian elimination for detailed explanations.

Before laying out the algorithm, we warn the reader that the coefficient matrix of the system will be denoted by both before and after performing an elementary row operation, even if the matrix resulting from the operation is in principle a different matrix.

The steps are listed below:

1. Start from and .

2. Increment by one unit.

3. Increment by one unit.

4. Stop the algorithm if . Else proceed to the next step.

5. If for , return to step 3. Else proceed to the next step.

6. Interchange the -th equation with any equation (with ) such that (if there is no need to perform an interchange).

7. Divide the -th equation by .

8. For and , subtract the -th equation multiplied by from the -th equation.

9. If , return to step 2. Else stop the algorithm.

The differences with respect to Gaussian elimination are the following:

• Step 7 is not found in the Gaussian elimination algorithm. In step 7, we divide the equation containing the current pivot by the value of the pivot itself. This is done to ensure that all pivots are equal to in the final system.

• In step 8, we perform elementary operations to annihilate not only the elements below the pivot (as in Gaussian elimination) but also those above it.

• In step 9, we stop at the last row, unlike in Gaussian elimination, where we stop at the penultimate row. The reason is that, if there is a pivot on the last row, we need to make it equal to , and we need to annihilate the entries above it.

## Examples

We present below an example of Gauss Jordan elimination.

In order to simplify the notation, we are going to use augmented matrices to represent linear systems.

Example Consider the system of three equations in four unknowns represented by the augmented matrix We start from row and column . Since , we do not perform any interchange of rows. We divide the first row by and obtain In order to annihilate the entries below the pivot , we subtract the first row multiplied by from the second and multiplied by from the third: We move to row and column . Since , but , we interchange the second row with the third: We divide the second row by : We add the second row multiplied by to the first: We move to row and column . We divide the third row by the value of its pivot : We add times the third row to the second and the third: The matrix is now in reduced row echelon form.

## Gauss Jordan elimination with pivoting

As in Gaussian elimination, in order to improve the numerical stability of the algorithm, we usually perform partial pivoting in step 6, that is, we always choose the row interchange that moves the largest element (in absolute value) to the pivotal position. If we also exchange columns in order to maximize the absolute value of the pivot, then we are doing complete pivoting. See the lecture on Gaussian elimination for more details on partial and complete pivoting.

## Solved exercises

Below you can find some exercises with explained solutions.

### Exercise 1

Transform the system into an equivalent system in reduced row echelon form. Use the Gauss Jordan elimination algorithm with partial pivoting.

Solution

The entry is non-zero and it is already the largest entry in the first column. Therefore, it is used as pivot. Divide the first row by : Annihilate the entries below the pivot : Interchange the second row with the third, so that the largest element moves to the pivotal position: Divide the second row by : Annihilate the entries above and below the pivot : Interchange the third row with the fourth: Divide the third row by : All the elements above and below the pivot are already zero, so we can move to the last row. There are no row interchanges to consider because there are no rows below the last. Furthermore, is a pivot and it is already equal to . Therefore, we only need to annihilate the elements above it: The system is now in reduced row echelon form.