Gauss-Jordan method
Calculating Inverses
When we have a nonhomogeneous system of equations , where is non-singular, we wish to calculate . One way to find is through Cramer's rule. However, this requires a lot of computation and it is easy to make mistakes. A more efficient method is the Gauss-Jordan method. This uses the row operations in matrices, which were explained previously in this chapter. This approach is illustrated by the following example; consider the system of equations
We express these in matrix form as follows,
where we have included the identity matrix on the RHS. We perform the following row operations and in Eq. (10.50) yielding,
The idea is as follows; the solution to is given by as mentioned before. If we perform row operations such that the matrix on the LHS of (10.50) (i.e. matrix ) becomes the identity matrix multiplying then the matrix on the RHS must turn into the inverse of . Performing followed by gives,
Finally, we do followed by and which gives,
The matrix on the RHS is therefore . To solve for , we need to calculate which gives , and .
Note that the order in which one may carry out these row operations is not unique. Next we discuss some general principles that may help when applying this technique.
(i) Exchange rows and divide the first row by a scalar in order to get a one in the top lefthand corner;
(ii) Take away multiples of the first row from the other rows to remove dependence on in the other rows;
(iii) Repeat step (i), but for the second column and second row to ensure we have a one in position 22 ;
(iv) Take away multiples of the second row from the other rows to ensure that we have zeros elsewhere; (v) Repeat column by column.
Example 10.8 Find the inverse of matrix given by
using the Gauss-Jordan method.
Solution We start by writing the matrix and the identity matrix side by side as,
Next, we perform the row operations and which gives,
We continue with and ,
We then do and divide the resulting by 5 ,
Finally, we do and divide the resulting by 5 and by -5 , giving
The matrix that appears on the RHS is .
Gaussian elimination
We can solve a system of equations without necessarily obtaining the inverse matrix using Gaussian elimination. The method we follow is the same as in Subsec. 10.5.1 but we reduce the coefficient matrix to upper triangular form. We saw an example of an upper triangular matrix in Subsec. 10.1.2. Further, this approach works whether the matrix is singular or not. We use Eq. (10.50) as an example and in particular the following form,
We undertake and as before so that we obtain zeros in the and positions, as follows
To make the coefficient matrix in (10.55) upper triangular we need to have a zero in the position. We take yielding,
Equation (10.56) gives us the equations to solve for , and . We see from the last row that , from the second row,
and from the first row,
We now revisit the matrix equation in Eq. (10.43) where we know the coefficient matrix to be singular. We first eliminate the final row by taking ,
We then let which gives,
We see from the last row that for consistency, we need . We again let the parameter for the under-determined equation and we have , so that in the second equation and in the first equation, we have so that as before. The process of solving upper triangular systems as above is referred to as back substitution. The process of obtaining the upper triangular form is known as forward elimination.
Exercises
- Solve the system of equations,
giving different cases for and .
Cramer's rule revisited
Recall that Cramer's rule relates the inverse of a matrix to its determinant and adjugate matrix [refer to Eq. (10.26)]. As previously mentioned, the solution to the matrix equation is given by
Using Eq. (10.26), we can write the solution as,
Cramer's rule can be used to solve systems of equations via the calculation of determinants and their ratio. Let us look at a quick example before generalising the method. Consider the following matrix equation,
Solving for and from the system of equations, i.e.
we obtain
Equations (10.61) can be expressed in terms of the following ratios of determinants
where,
Note that in the expression for , the coefficients of i.e. are replaced by and, similarly, in , the coefficients of i.e. are replaced by where . The unique solution to Eqs. (10.60) is given by Eqs. (10.62) provided . If , this method of obtaining the solution cannot be used. Now let us go back to Cramer's rule and Eq. (10.59) to generalise. We realise that evaluating can be expressed in a neat way by writing it out in component form,
The formula for the determinant of a matrix (summing over columns) is given by
where represents the index column, i.e. if we expand along the first column, if we expand along the second, etc. Equation 10.65 holds for an square matrix.
Consider now the following matrix,
Suppose now we were to expand Eqs. (10.64) and (10.65) for column 1 (i.e. ) for the matrix equation (10.66). This yields,
It follows, that Eq. (10.64) gives the determinant of the matrix when the column [i.e. for column 1 , we have has been replaced by the vector . Note that the components of the first column give the coefficients of when the equations are expanded
similarly, are the coefficients of and , respectively. With the above observations, we may use Cramer's rule (10.59) to find the value of , and separately via the following relations,
Example 10.9 Use Cramer's rule in order to determine what the value of is in the solution of,
Solution Starting from Cramer's rule we have
where is the coefficient matrix in the matrix equation and . To determine , we use
where is the determinant of matrix with the first column replaced by and is the determinant of ,
Using row transformations or by direct calculation, we find that hence .
While Cramer's rule is useful in obtaining a single value of the unknown vector without knowing any of the other vector values, it can get computationally expensive with larger matrices. Further, if , we know that the system of equations we are trying to solve admits either no solutions or infinitely many solutions; however, a different technique must be used to obtain the solutions.
In this section we have discussed the Gauss-Jordan method, Gaussian elimination, and Cramer's rule for solving linear systems. The Gauss-Jordan method is used when we want to fully invert a matrix. To solve a system of equations, we may use Gaussian elimination to obtain an upper triangular matrix by undertaking row operations; then the last row gives us the component of an matrix and through back substitution we can solve for the remaining components. Finally, if we wish to obtain a single component of an unknown vector (like the -component in Example 10.9), we may use Cramer's rule.
Exercises
- Find the inverse matrix of
- Find the solution of the following system of equations using Gaussian elimination,
- Find the value of using Cramer's rule in the following system of equations,