Fundamentals of Statistics contains material of various lectures and courses of H. Lohninger on statistics, data analysis and here for more.

Gauss-Jordan Algorithm

The Gauss-Jordan algorithm can be used to solve linear equations and/or to calculate the inverse of a matrix. The Gauss-Jordan algorithm is based on equivalence operations. While this algorithm is easy to understand, it is not the best way to solve linear equations, since it takes up to three times longer than the best algorithms available, and requires additional storage space.

The principle of the algorithm is simple: the system of linear equations to be solved is denoted as a rectangular matrix (the coefficients, and the constants of the equations system), optionally enlarged by an identity matrix, if the inverted matrix is also required. This rectangular matrix is now changed and rearranged by equivalence operations in such a way that the original sub-matrix of the coefficients of the equations becomes an identity matrix.

As an example, suppose you have to solve the following system of linear equations:

First, we have to align the unknown variables. Variables which are not used in a particular equation are entered with a coefficient of zero:

From this aligned system of equations we extract the coefficients on the left side, and the constants on the right side (blue) to form a rectangular matrix:

If we need for some reason the inverse of the coefficient matrix, we also have to add the identity matrix (red), so that we finally start with the following matrix:

In order to solve this system, we have to apply equivalence operations in such a way that the black square sub-matrix becomes the identity matrix. In doing so, we obtain the following  matrix:

Now the blue vector contains the solutions, and the red former identity matrix contains the inverse of the original (black) coefficient matrix. Thus, the solution of the system of linear equations is:

x1 = 2
x2 = -1
x3 = 5