Lab for Matrix Inversion

Module for Matrix Inversion

   Check out the new Numerical Analysis Projects page.

Gauss-Jordan Method for Matrix Inversion. Construct the inverse for the matrix A, by using Gaussian elimination. Let the coefficients of A and the identity matrix I be stored in the augmented matrix [A, I] = ([Graphics:mi.txtgr1.gif]) which has n rows and 2n columns. The system can be written
[Graphics:mi.txtgr2.gif][Graphics:mi.txtgr3.gif]
Row operations will be used to eliminate [Graphics:mi.txtgr4.gif] in column p. This is equivalent to solving the n linear systems
[Graphics:mi.txtgr5.gif]where [Graphics:mi.txtgr6.gif] is the i-th base vector.
Remark. In the following subroutine the notation i=!=p means "i not equal to j".

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr7.gif]
 
 

Report to be handed in.

Computer Exercises
 

 

Exercise 1. Find the inverse of the matrix

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr9.gif]

First, form the augmented matrix [A, I] and store it in the variable AI.

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr10.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr11.gif]

Second, construct the inverse matrix using Gauss-Jordan elimination.
Remark. All the computations are printed too !

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr12.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr13.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr14.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr15.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr16.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr17.gif]

Extract the inverse matrix B. from the augmented matrix M = [I,B].

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr18.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr19.gif]

Verify that B is the inverse of A.

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr20.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr21.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr22.gif]
 
 

Exercise 2. Find the inverse of the 5x5 Hilbert matrix

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr23.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr24.gif]

First, form the augmented matrix [A, I] and store it in the variable AI.

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr25.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr26.gif]

Second, construct the inverse matrix using Gauss-Jordan elimination.
Remark. All the computations are printed too !

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr27.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr28.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr29.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr30.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr31.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr32.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr33.gif]

Extract the inverse matrix B. from the augmented matrix M = [I,B].

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr34.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr35.gif]

Verify that B is the inverse of A.

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr36.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr37.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr38.gif]
 
 

Exercise 3. Hilbert matrices are known to be ill-conditioned. Find the inverse of the 5x5 matrix that approximates the 5x5 Hilbert matrix.

Remark. The entries in the matrix for this exercise must be typed in by hand in order to make sure that only six decimal places are stored in the computer.

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr39.gif]

First, form the augmented matrix [A, I] and store it in the variable AI.

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr40.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr41.gif]

Second, construct the inverse matrix using Gauss-Jordan elimination.
Remark. All the computations are printed too !

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr42.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr43.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr44.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr45.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr46.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr47.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr48.gif]

Extract the inverse matrix B. from the augmented matrix M = [I,B].

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr49.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr50.gif]

Verify that B is the inverse of A.

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr51.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr52.gif]

Everything might appear to be working nicely, but compare the inverse of the Hilbert matrix using exact arithmetic with the inverse of the chopped Hilbert matrix

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr53.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr54.gif]

Observe the difference between the computed inverse matrices when the Hilbert matrix is chopped.

[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr55.gif]
[Graphics:mi.txtgr8.gif][Graphics:mi.txtgr56.gif]

What is your conclusion regarding the propagation of error ?

 

 

 

(c) John H. Mathews, 1998