The inverse of a matrix
Here is one way how Maple can find the inverse of a matrix. Using MAple I will show you the algorithm of finding the inverse, using at the same time the elementary matrices that acieve at each step in the algorithm the elementary row operations.
| > | with(LinearAlgebra); |
Example 1. We look at exercise 7(a) in Anton&Rorres. We will define the elementary matrices that will perform the row operations on the matrix A to reduceit to its reduced-row-echelon form.
| > | A:=Matrix([[3,4,-1],[1,0,3],[2,5,-4]]); |
| > | MatrixInverse(A); |
The first step is to get an 1 on the first row, first column. We will interchange the first and second row. At the same time we define the elementary matrix E1 that does just that. We also check that
achieves exactly that step.
| > | E1:=Matrix([[0,1,0],[1,0,0],[0,0,1]]); |
| > | A1:=Multiply(E1,A); |
Now we will get zeros on the first column in the secnd and third row by subtracting three times the first row from the second row and subtracting twice the first row from the third row, respectively. Again we define two new elementary matrices:
| > | E2:=Matrix([[1,0,0],[-3,1,0],[0,0,1]]);E3:=Matrix([[1,0,0],[0,1,0],[-2,0,1]]); |
Again, by multiplying the matrix A1 to the left by the matrix E2 and then by E3 we obtain the desired result.
| > | A2:=Multiply(E2,A1); |
| > | A3:=Multiply(E3,A2); |
Now we want to get 1 on the second row. We just divide by 4 the entire row (Maple can handle that). So here is the matrix that achieves that row operation and the transformed matrix:
| > | E4:=Matrix([[1,0,0],[0,1/4,0],[0,0,1]]); |
| > | A4:=Multiply(E4,A3); |
Next we get zero in the second column, row three by subtracting fives times the second row from the third row:
| > | E5:=Matrix([[1,0,0],[0,1,0],[0,-5,1]]); |
| > | A5:=Multiply(E5,A4); |
Next step is to multiply the third row by 2/5:
| > | E6:=Matrix([[1,0,0],[0,1,0],[0,0,2/5]]); |
| > | A6:=Multiply(E6,A5); |
Now we have to more stps to get zero in the third column, above the pivot. We first add 5/2 the third row to the second row and then subtract three times the third row from the first row:
| > | E7:=Matrix([[1,0,0],[0,1,5/2],[0,0,1]]); |
| > | A7:=Multiply(E7,A6); |
| > | E8:=Matrix([[1,0,-3],[0,1,0],[0,0,1]]); |
| > | A8:=Multiply(E8,A7); |
So we have that
and therefore the inverse of the matrix A (think that you multiply by the inverse of A to the right of the equation above) equals the product of the eight elementary matrices. Let us check that. Unfortunately, we have to multiply only two matrices at a time:
| > | B1:=Multiply(E8,E7); |
| > | B2:=Multiply(B1,E6); |
| > | B3:=Multiply(B2,E5); |
| > | B4:=Multiply(B3,E4); |
| > | B5:=Multiply(B4,E3); |
| > | B6:=Multiply(B5,E2); |
| > | B7:=Multiply(B6,E1); |
And this last matrix, B7 should be the inverse of A, and as you can verify, it is the same matrix given by the Matrixinverse command at the top of the worksheet.
| > |