Linear Programming Lecture Notes - Penn State Personal Web Server
Linear Programming Lecture Notes - Penn State Personal Web Server
Linear Programming Lecture Notes - Penn State Personal Web Server
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Gauss-Jordan Elimination<br />
Computing an Inverse<br />
(1) Let A ∈ Rn×n . Let X = [A|In].<br />
(2) Let i := 1<br />
(3) If Xii = 0, then use row-swapping on X to replace row i with a row j (j > i) so that<br />
Xii = 0. If this is not possible, then A is not invertible.<br />
(4) Replace Xi· by (1/Xii)Xi·. Element (i, i) of X should now be 1.<br />
(5) For each j = i, replace Xj· by −Xji<br />
Xii Xi· + Xj·.<br />
(6) Set i := i + 1.<br />
(7) If i > n, then A has been replaced by In and In has been replaced by A−1 in X. If<br />
i ≤ n, then goto Line 3.<br />
Algorithm 5. Gauss-Jordan Elimination for Matrix Inversion<br />
Step 5 (i = 1): We multiply row 1 of X by −3 and add the result to row 2 of X to<br />
obtain:<br />
<br />
1<br />
X :=<br />
0<br />
2<br />
−2<br />
1<br />
−3<br />
<br />
0<br />
1<br />
Step 6: i := 1 + 1 = 2 and i = n so we return to Step 3.<br />
Steps 3 (i = 2): The new element A22 = −2 = 0. Therefore, no swapping is required.<br />
Step 4 (i = 2): We replace row 2 of X with row 2 of X multiplied by −1/2.<br />
<br />
1 2 1 0<br />
X :=<br />
0 1 3<br />
2<br />
− 1<br />
2<br />
Step 5 (i = 2): We multiply row 2 of X by −2 and add the result to row 1 of X to<br />
obtain:<br />
<br />
1<br />
X :=<br />
0 −2 1<br />
<br />
0 1 3<br />
2<br />
1 − 2<br />
Step 6 (i = 2): i := 2 + 1 = 3. We now have i > n and the algorithm terminates.<br />
Thus using Algorithm 5 we have computed:<br />
A −1 <br />
−2 1<br />
=<br />
3<br />
2<br />
1 − 2<br />
This value should be the result you obtained in Exercise 27.<br />
Exercise 28. Does the matrix:<br />
⎡ ⎤<br />
1 2 3<br />
A = ⎣4 5 6⎦<br />
7 8 9<br />
have an inverse? [Hint: Use Gauss-Jordan elimination to find the answer.]<br />
Exercise 29 (Bonus). Implement Gauss-Jordan elimination in the programming language<br />
of your choice. Illustrate your implementation by using it to solve the previous exercise.<br />
[Hint: Implement sub-routines for each matrix operation. You don’t have to write them as<br />
matrix multiplication, though in Matlab, it might speed up your execution. Then use these<br />
subroutines to implement each step of the Gauss-Jordan elimination.]<br />
36