3.4 Inverses
In-class demo by Russell Blyth.
> restart: with(linalg):
Warning, the protected names norm and trace have been redefined and unprotected
We start with a random 3 x 3 matrix.
> A:= randmatrix(3,3,entries=rand(-3..3));
Find the inverse of the matrix A. The equation Y = AX computes Y given X. We need to compute X given Y. Define a general Y, and solve for X:
>
Y := vector(3,[y1,y2,y3]);
AugA := augment(A,Y);
RedA := gaussjord(AugA);
Let's extract the expression for X in terms of Y
> Xvec := delcols(RedA,1..3);
>
y1vec := subs(y1=1,y2=0,y3=0,op(Xvec));
y2vec := subs(y1=0,y2=1,y3=0,op(Xvec));
y3vec := subs(y1=0,y2=0,y3=1,op(Xvec));
Thus Xvec = y1*y1vec + y2*y2vec + y3*y3vec. If we make a matrix with y1vec, y2vec, y3vec as the columns, then y1, y2 and y3 are the coefficients of the linear combination giving X. We write this as BY, where
> B := augment(y1vec,y2vec,y3vec);
Check:
> evalm(B&*Y);
This is just the transpose of Xvec. Thus X = BY. B is the inverse of A!
Check the products AB and BA:
>
evalm(A&*B);
evalm(B&*A);
Note the first column of B arises from solving AX =
; the second column from solving AX =
and the third column from solving AX =
. These three systems may be solved simultaneously, by finding the reduced row echelon form of the matrix [A,I]
>
I3 := array(identity,1..3,1..3);
BigA := augment(A,I3);
RedBigA := gaussjord(BigA);
Note the final three columns are precisely the inverse matrix B.
Maple has a built-in inverse command:
> inverse(A);
>
>