> with(linalg);
Take a matrix
> A:=matrix([[1,2],[3,4]]);
And the identity matrix
> Id:=matrix([[1,0],[0,1]]);
Augment them
> B:=augment(A,Id);
B := |
[ 1 |
2 |
1 |
0 ] |
[ 3 |
4 |
0 |
1 ] |
Look what happens when we do a row operation
to this matrix: this operation is applied simultaneously to both A and Id
> C:=addrow(B,1,2,-3);
C := |
[ 1 |
2 |
1 |
0 ] |
[ 0 |
-2 |
-3 |
1 ] |
Now do the Gauss-Jordan procedure
> F:=gaussjord(C);
F := |
[ 1 |
0 |
-2 |
1 ] |
[ 0 |
1 |
3/2 |
-1/2 ] |
The left half of this matrix is the identity matrix, so the right part must be the inverse of A.
> FF:=matrix([[-2,1],[3/2,-1/2]]);
FF := |
[ -2 |
1 ] |
[ 3/2 |
-1/2 ] |
Check it:
> evalm(A&*FF);