Lesson 3 (B)
Lesson 3 (B)
Lesson 3
Linear System
A. Non iterative method
i. Graphical method
ii. Determinant and Cramer’s rule
iii. Naïve Gauss elimination
iv. Pivoting
v. Tridiagonal System
vi. Gauss Jordan method
vii. LU decomposition
viii. Inverse of matrix
ix. Cholesky Factorization/Decomposition
B. Iterative method
i. Gauss-Seidel method
ii. Jacobi iteration
Partial Pivoting
The primary reason that the foregoing technique is called “naïve”. is that during both the elimination and
the back-substitution phases, it is possible that a division by zero can occur. The normalization of the first
row would involve division by a11 = 0.
3
Partial Pivoting
The primary reason that the foregoing technique is called “naïve”. is that during both the elimination and
the back-substitution phases, it is possible that a division by zero can occur. The normalization of the first
row would involve division by a11 = 0.
o The Naive Gaussian Elimination may fail for very simple cases. (The pivoting element is
zero).
0 1 𝑥1 1
=
1 1 𝑥2 2
o Very small pivoting element may result in serious computation errors
10−10 1 𝑥1 = 1
1 1 𝑥2 2
4
Partial Pivoting
The primary reason that the foregoing technique is called “naïve”. is that during both the elimination and
the back-substitution phases, it is possible that a division by zero can occur. The normalization of the first
row would involve division by a11 = 0.
Therefore, before each row is normalized, it is advantageous to determine the coefficient with the
largest absolute value in the column below the pivot element. The rows can then be switched so that the
largest element is the pivot element. This is called partial pivoting.
5
Step by Step algorithm
1. Determine the largest number (regardless of sign) in each row of Matrix A to determine the Scale vector
2. To determine the first pivot equation, Determine the ratio of the first element to the Scale vector such as
𝑎𝑙𝑖,𝑛
𝑅𝑎𝑡𝑖𝑜𝑠 = 𝑤ℎ𝑒𝑟𝑒 𝑙 − 𝑖𝑛𝑑𝑒𝑥 𝑣𝑒𝑐𝑡𝑜𝑟 𝑓𝑟𝑜𝑚 𝑖 = 1 𝑡𝑜 𝑛 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛
𝑆𝑙𝐼
𝑆 − 𝑆𝑐𝑎𝑙𝑒 𝑣𝑒𝑐𝑡𝑜𝑟 𝑎𝑙𝑖,1 − 𝑓𝑖𝑟𝑠𝑡 𝑒𝑙𝑒𝑚𝑒𝑛𝑡 𝑜𝑓 𝑡ℎ𝑒 𝑖𝑛𝑑𝑒𝑥 𝑣𝑒𝑐𝑡𝑜𝑟
Then , determine the highest ratio which will serve as the first pivot.
3. To eliminate the unknown, use the rule for Forward elimination
4. Repeat step 2 to 3 until the form became similar to an upper triangular matrix.
5. Rearrange the equation accordingly.
5. Use backward substitution to determine the value of the unknowns.
6
Example Problem:
1. Use Gaussian Elimination with Scaled Partial pivoting to solve:
1.1𝑥1 − 5𝑥2 − 0.2𝑥3 = 7.85 (1)
𝑥1 − 0.3𝑥2 + 7𝑥3 = −19.5 (2)
3𝑥1 − 0.2𝑥2 + 10𝑥3 = 71.4 (3)
7
Example Problem:
1. Use Gaussian Elimination with Scaled Partial pivoting to solve:
1.1𝑥1 − 5𝑥2 − 0.2𝑥3 = 7.85 (1)
𝑥1 − 0.3𝑥2 + 7𝑥3 = −19.5 (2)
3𝑥1 − 0.2𝑥2 + 10𝑥3 = 71.4 (3)
Solution :
1.1 −5 −0.2 𝑥1 7.85
1 −0.3 7 𝑥2 = −19.5
3 −0.2 10 𝑥3 71.4
8
Example Problem:
1. Use Gaussian Elimination with Scaled Partial pivoting to solve:
1.1𝑥1 − 5𝑥2 − 0.2𝑥3 = 7.85 (1)
𝑥1 − 0.3𝑥2 + 7𝑥3 = −19.5 (2)
3𝑥1 − 0.2𝑥2 + 10𝑥3 = 71.4 (3)
Solution :
1.1 −5 −0.2 𝑥1 7.85
1 −0.3 7 𝑥2 = −19.5
3 −0.2 10 𝑥3 71.4
9
Example Problem:
1. Use Gaussian Elimination with Scaled Partial pivoting to solve:
1.1𝑥1 − 5𝑥2 − 0.2𝑥3 = 7.85 (1)
𝑥1 − 0.3𝑥2 + 7𝑥3 = −19.5 (2)
3𝑥1 − 0.2𝑥2 + 10𝑥3 = 71.4 (3)
Solution :
1.1 −5 −0.2 𝑥1 7.85
1 −0.3 7 𝑥2 = −19.5
3 −0.2 10 𝑥3 71.4
𝑎𝑙𝑖,1 1.1 1 3
𝑅𝑎𝑡𝑖𝑜𝑠 = = , ,
𝑆𝑙𝐼 5 7 10
10
Example Problem:
1. Use Gaussian Elimination with Scaled Partial pivoting to solve:
1.1𝑥1 − 5𝑥2 − 0.2𝑥3 = 7.85 (1)
𝑥1 − 0.3𝑥2 + 7𝑥3 = −19.5 (2)
3𝑥1 − 0.2𝑥2 + 10𝑥3 = 71.4 (3)
Solution :
1.1 −5 −0.2 𝑥1 7.85
1 −0.3 7 𝑥2 = −19.5
3 −0.2 10 𝑥3 71.4
𝑎𝑙𝑖,1 1.1 1 3
𝑅𝑎𝑡𝑖𝑜𝑠 = = , , → 𝑚𝑎𝑥 𝑐𝑜𝑟𝑟𝑒𝑠𝑝𝑜𝑛𝑑𝑠 𝑡𝑜 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛 3
𝑆𝑙𝐼 5 7 10
Hence, the pivot equation will be equation 3
11
Example Problem:
1. Use Gaussian Elimination with Scaled Partial pivoting to solve:
1.1𝑥1 − 5𝑥2 − 0.2𝑥3 = 7.85 (1)
𝑥1 − 0.3𝑥2 + 7𝑥3 = −19.5 (2)
3𝑥1 − 0.2𝑥2 + 10𝑥3 = 71.4 (3)
Solution:
Using forward elimination , multiply equation (3) by 1/3 and subtract from eq. (2):
𝑎21
𝑒𝑞 2 − 𝑒𝑞(3)
𝑎31
1
𝑥1 − 0.3𝑥2 + 7𝑥3 + 19.5 − 3𝑥1 − 0.2𝑥2 + 10𝑥3 − 71.4 = −0.2333𝑥2 + 3.6667𝑥3 + 43.3
3
To eliminate x2 from equation 5 , multiply equation (4) by -0.2333/-4.9267 and subtract from eq. (5):
𝑎22 ′
𝑒𝑞 5 − 𝑒𝑞(4)
𝑎12′
−0.2333
−0.2333𝑥2 + 3.667𝑥3 + 43.3 − −4.9267𝑥2 − 3.8667𝑥3 + 18.33 = 3.8498𝑥3 + 42.4319
−4.2967
Hence, the new equation will be
−4.9267𝑥2 − 3.8667𝑥3 = −18.33 (7)
3.8498𝑥3 = −42.4319 (8)
3𝑥1 − 0.2𝑥2 + 10𝑥3 = 71.4 (9)
13
Rearranging equation (7) to (9) to form an upper triangular matrix form will yield,
14
Rearranging equation (7) to (9) to form an upper triangular matrix form will yield,
Using backward substitution from equation (9) to (7) to determine the unknowns,
−42.4319
𝑥3 = = −11.0218
3.8498
−18.33 − (−3.8667)(−11.0218)
𝑥2 = = 12.371
−4.9267
71.4 − −0.2 12.371 − (10)(−11.0218)
𝑥1 = = 61.3642
3
15
Example Problem:
2. Use Gaussian Elimination with Scaled Partial pivoting to solve :
𝑥2 + 1.3𝑥3 + 2𝑥4 = 8 (1)
𝑥1 + 3𝑥2 + 9𝑥3 + 3𝑥4 = 6.3 (2)
5𝑥1 + 2𝑥2 + 7𝑥3 + 3𝑥4 = 9 (3)
2𝑥1 + 3𝑥2 + 4𝑥3 + 6𝑥4 = 3 (4)
Solution :
0 1 1.3 2 𝑥1 8
1 3 9 3 𝑥2 6.3
𝑥3 =
5 2 7 3 9
2 3 4 6 𝑥4 3
16
Example Problem:
2. Use Gaussian Elimination with Scaled Partial pivoting to solve :
𝑥2 + 1.3𝑥3 + 2𝑥4 = 8 (1)
𝑥1 + 3𝑥2 + 9𝑥3 + 3𝑥4 = 6.3 (2)
5𝑥1 + 2𝑥2 + 7𝑥3 + 3𝑥4 = 9 (3)
2𝑥1 + 3𝑥2 + 4𝑥3 + 6𝑥4 = 3 (4)
Solution :
0 1 1.3 2 𝑥1 8
1 3 9 3 𝑥2 6.3
𝑥3 =
5 2 7 3 9
2 3 4 6 𝑥4 3
17
Example Problem:
2. Use Gaussian Elimination with Scaled Partial pivoting to solve :
𝑥2 + 1.3𝑥3 + 2𝑥4 = 8 (1)
𝑥1 + 3𝑥2 + 9𝑥3 + 3𝑥4 = 6.3 (2)
5𝑥1 + 2𝑥2 + 7𝑥3 + 3𝑥4 = 9 (3)
2𝑥1 + 3𝑥2 + 4𝑥3 + 6𝑥4 = 3 (4)
Solution :
0 1 1.3 2 𝑥1 8
1 3 9 3 𝑥2 6.3
=
5 2 7 3 𝑥3 9
2 3 4 6 𝑥4 3
𝑎𝑙𝑖,1 0 1 5 2
𝑅𝑎𝑡𝑖𝑜𝑠 = = , , , → 𝑚𝑎𝑥 𝑐𝑜𝑟𝑟𝑒𝑠𝑝𝑜𝑛𝑑𝑠 𝑡𝑜 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛 3
𝑆𝑙𝐼 2 9 7 6
Hence, the pivot equation will be equation 3
18
Using forward elimination , multiply equation (3) by 1/5 and subtract from eq. (2):
𝑎21
𝑒𝑞 2 − 𝑒𝑞(3)
𝑎31
1
𝑥1 + 3𝑥2 + 9𝑥3 + 3𝑥4 − 6.3 − 5𝑥1 + 2𝑥2 + 7𝑥3 + 3𝑥4 − 9 = 2.6𝑥2 + 7.6𝑥3 + 2.4𝑥3 − 4.5
5
19
To eliminate x2 from eq. (6) and (8) , multiply equation (5) by 2.6 and subtract from eq. (6):
𝑎22 ′
𝑒𝑞 6 − 𝑒𝑞(5)
𝑎12 ′
2.6𝑥2 + 7.6𝑥3 + 2.4𝑥4 − 4.5 − 2.6 𝑥2 + 1.3𝑥3 + 2𝑥4 − 8 = 4.22𝑥3 − 2.8𝑥3 + 16.3
Multiply eq (5) by 2.2 and subtract from eq (8):
𝑎42 ′
𝑒𝑞 8 − 𝑒𝑞(5)
𝑎12 ′
2.2𝑥2 + 1.2𝑥3 + 4.8𝑥4 + 0.6 − 2.2 𝑥2 + 1.3𝑥3 + 2𝑥4 − 8 = −1.66𝑥3 + 0.4𝑥4 + 18.2
Hence the new equation, in matrix form will be:
0 1 1.3 2 𝑥1 8
0 0 4.22 −2.8 𝑥2 −16.3
𝑥3 =
5 2 7 3 9
0 0 −1.66 0.4 𝑥4 −18.2
𝑎𝑙𝑖,3 4.22 1.66
𝑅𝑎𝑡𝑖𝑜𝑠 = = , → 𝑚𝑎𝑥 𝑐𝑜𝑟𝑟𝑒𝑠𝑝𝑜𝑛𝑑𝑠 𝑡𝑜 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛 10
𝑆𝑙𝐼 9 6
Hence, the pivot equation will be equation 10
20
To eliminate x3 from eq. (12) , multiply equation (10) by -1.66/4.22 and subtract from eq. (12):
𝑎43 ′′
𝑒𝑞 12 − 𝑒𝑞(101)
𝑎23 ′′
−1.66
−1.66𝑥3 + 0.4𝑥4 + 18.2 − 4.22𝑥3 − 2.88𝑥4 + 16.3 = −0.70142𝑥3 + 24.6118
4.22
21
Using backward substitution from equation (16) to (13) to determine the unknowns,
−24.6118
𝑥4 = = 35.0885
−0.70142
−16.33 − (−2.8)(35.0885)
𝑥3 = = 19.4189
−4.22
8 − 1.3 19.4189 − (2)(35.0885)
𝑥2 = = −87.4216
1
9 − 2 −87.4216 − 7 19.4189 − 3 35.0885
𝑥1 = = −11.4709
5
22
Tridiagonal Systems
23
Tridiagonal Systems
29
Solving Tridiagonal System
Forward Elimination
𝑎𝑖−1
𝑑𝑖 ′ = 𝑑𝑖 − 𝑐𝑖−1
𝑑𝑖−1
′ 𝑎𝑖−1
𝑏𝑖 = 𝑏𝑖 − 𝑏𝑖−1 2≤𝑖≤𝑛
𝑑𝑖−1
Backward Substitution
𝑏𝑛
𝑥𝑛 =
𝑑𝑛
1
𝑥𝑖 = 𝑏𝑖 − 𝑐𝑖 𝑥𝑖+1 for 𝑖 = 𝑛 − 1, 𝑛 − 2, . . . , 1
𝑑𝑖
30
Diagonal Dominance
Matrix 𝐴 is diagonally dominant if
𝑛
31
Diagonal Dominance
Examples:
3 0 1 −3 0 1
1 6 1 2 3 2
1 2 −5 1 2 1
Diagonally dominant Not Diagonally dominant
32
Diagonally Dominant Tridiagonal System
33
Example Problem:
3. Use Tridiagonal system to solve :
𝑥1 + 1.3𝑥2 = 8 (1)
5𝑥1 + 3𝑥2 + 9𝑥3 = 6.3 (2)
2𝑥2 + 7𝑥3 + 3𝑥4 = 9 (3)
4𝑥3 + 6𝑥4 = 3 (4)
34
Example Problem:
3. Use Tridiagonal system to solve :
𝑥1 + 1.3𝑥2 = 8 (1)
5𝑥1 + 3𝑥2 + 9𝑥3 = 6.3 (2)
2𝑥2 + 7𝑥3 + 3𝑥4 = 9 (3)
4𝑥3 + 6𝑥4 = 3 (4)
Solution :
1 1.3 0 0 𝑥1 8
5 3 9 0 𝑥2 6.3
𝑥3 =
0 2 7 3 9
0 0 4 6 𝑥4 3
35
Example Problem:
3. Use Tridiagonal system to solve :
𝑥1 + 1.3𝑥2 = 8 (1)
5𝑥1 + 3𝑥2 + 9𝑥3 = 6.3 (2)
2𝑥2 + 7𝑥3 + 3𝑥4 = 9 (3)
4𝑥3 + 6𝑥4 = 3 (4)
Solution :
1 1.3 0 0 𝑥1 8
5 3 9 0 𝑥2 6.3
=
0 2 7 3 𝑥3 9
0 0 4 6 𝑥4 3
𝑇
𝑐 = 1.3 9 3
𝑑𝑇 = 1 3 7 3
𝑎𝑇 = 5 2 4
𝑏𝑇 = 8 6.3 9 3
36
Example Problem:
3. Use Tridiagonal system to solve :
𝑥1 + 1.3𝑥2 = 8 (1)
5𝑥1 + 3𝑥2 + 9𝑥3 = 6.3 (2)
2𝑥2 + 7𝑥3 + 3𝑥4 = 9 (3)
4𝑥3 + 6𝑥4 = 3 (4)
Solution :
1 1.3 0 0 𝑥1 8
5 3 9 0 𝑥2 6.3
=
0 2 7 3 𝑥3 9
0 0 4 6 𝑥4 3
𝑇
𝑐 = 1.3 9 3
𝑑𝑇 = 1 3 7 3
𝑎𝑇 = 5 2 4
𝑏𝑇 = 8 6.3 9 3
𝑎𝑖−1
𝑑𝑖 ′ = 𝑑𝑖 − 𝑐
𝑑𝑖−1 𝑖−1
𝑎𝑖−1
𝑏𝑖 ′ = 𝑏𝑖 − ( )𝑏
𝑑𝑖−1 𝑖−1
37
𝑐 𝑇 = 1.3 9 3
𝑑𝑇 = 1 3 7 6
𝑎𝑇 = 5 2 4
𝑏𝑇 = 8 6.3 9 3
′
𝑎1 5
𝑑2 = 𝑑2 − 𝑐 =3− (1.3) = −3.5
𝑑1 1 1
𝑎2 2
𝑑3′ = 𝑑3 − 𝑐2 = 7 − (9) = 12.14286
𝑑2 ′ −3.5
𝑎3 4
𝑑4′ = 𝑑4 − 𝑐3 = 6 − (3) = 5.01176
𝑑3 ′ 12.14286
38
𝑐 𝑇 = 1.3 9 3
𝑑𝑇 = 1 3 7 6
𝑎𝑇 = 5 2 4
𝑏𝑇 = 8 6.3 9 3
′
𝑎1 5
𝑑2 = 𝑑2 − 𝑐 =3− (1.3) = −3.5
𝑑1 1 1
𝑎2 2
𝑑3′ = 𝑑3 − 𝑐2 = 7 − (9) = 12.14286
𝑑2 ′ −3.5
𝑎3 4
𝑑4′ = 𝑑4 − 𝑐3 = 6 − (3) = 5.01176
𝑑3 ′ 12.14286
𝑎1 5
𝑏2′ = 𝑏2 − 𝑏1 = 6.3 − (8) = −33.7
𝑑1 1
𝑎2 ′ 2
𝑏3′ = 𝑏3 − 𝑏2 = 9 − (−33.7) = −10.25714
𝑑2 ′ −3.5
𝑎3 ′ 4
𝑏4′ = 𝑏4 − 𝑏3 = 3 − (−10.25714) = 6.37882
𝑑3 ′ 12.14286
39
𝑐 𝑇 = 1.3 9 3
𝑑𝑇 = 1 3 7 6
𝑎𝑇 = 5 2 4
𝑏𝑇 = 8 6.3 9 3
′
𝑎1 5
𝑑2 = 𝑑2 − 𝑐 =3− (1.3) = −3.5
𝑑1 1 1
𝑎2 2
𝑑3′ = 𝑑3 − 𝑐2 = 7 − (9) = 12.14286
𝑑2 ′ −3.5
𝑎3 4
𝑑4′ = 𝑑4 − 𝑐3 = 6 − (3) = 5.01176
𝑑3 ′ 12.14286
𝑎1 5
𝑏2′ = 𝑏2 − 𝑏1 = 6.3 − (8) = −33.7
𝑑1 1
𝑎2 ′ 2
𝑏3′ = 𝑏3 − 𝑏2 = 9 − (−33.7) = −10.25714
𝑑2 ′ −3.5
𝑎3 ′ 4
𝑏4′ = 𝑏4 − 𝑏3 = 3 − (−10.25714) = 6.37882
𝑑3 ′ 12.14286
𝑑′𝑇 = 1 −3.5 12.14286 5.01176
𝑏′𝑇 = 8 −33.7 −10.25714 6.37882
40
Thus, the new matrix form will be,
1 1.3 0 0 𝑥1 8
0 −3.5 9 0 𝑥2 −33.7
𝑥3 =
0 0 12.14286 3 −10.25714
0 0 0 5.01176 𝑥4 6.37882
41
Thus, the new matrix form will be,
1 1.3 0 0 𝑥1 8
0 −3.5 9 0 𝑥2 −33.7
𝑥3 =
0 0 12.14286 3 −10.25714
0 0 0 5.01176 𝑥4 6.37882
𝑏𝑛 1
𝑥𝑛 = 𝑥𝑖 = 𝑏 − 𝑐𝑖 𝑥𝑖+1
𝑑𝑛 𝑑𝑖 𝑖
𝑏4 ′ 6.37882
𝑥4 = = = 1.27277
𝑑4 ′ 5.01176
𝑏3′ − (𝑐3 𝑥4 ) −10.25714 − 3𝑥1.27277
𝑥3 = = = −1.15915
𝑑3 ′ 12.14286
𝑏2′ − (𝑐2 𝑥3 ) −33.7 − 9𝑥 − 1.15915
𝑥2 = = = 6.6479
𝑑2 ′ −3.5
𝑏1 − (𝑐1 𝑥2 ) 8 − 1.3𝑥6.6479
𝑥1 = = = −0.64227
𝑑1 1
42
Example Problem:
4. Use Tridiagonal system to solve the value of the unknown currents in a five loop mesh circuit:
3𝐼1 + 5𝐼2 = 10 (1)
6𝐼1 + 5𝐼2 + 8𝐼3 = 11 (2)
8𝐼2 + 6𝐼3 + 2𝐼4 = 12 (3)
𝐼3 + 8𝐼4 + 3𝐼5 = 13 (4)
5𝐼4 + 7𝐼5 = 14 (5)
43
Example Problem:
4. Use Tridiagonal system to solve the value of the unknown currents in a five loop mesh circuit:
3𝐼1 + 5𝐼2 = 10 (1)
6𝐼1 + 5𝐼2 + 8𝐼3 = 11 (2)
8𝐼2 + 6𝐼3 + 2𝐼4 = 12 (3)
𝐼3 + 8𝐼4 + 3𝐼5 = 13 (4)
5𝐼4 + 7𝐼5 = 14 (5)
Solution :
3 5 0 0 0 𝐼1 10
6 5 8 0 0 𝐼2 11
0 8 6 2 0 𝐼3 = 12
0 0 1 8 3 𝐼4 13
0 0 0 5 7 𝐼5 14
44
Example Problem:
4. Use Tridiagonal system to solve the value of the unknown currents in a five loop mesh circuit:
3𝐼1 + 5𝐼2 = 10 (1)
6𝐼1 + 5𝐼2 + 8𝐼3 = 11 (2)
8𝐼2 + 6𝐼3 + 2𝐼4 = 12 (3)
𝐼3 + 8𝐼4 + 3𝐼5 = 13 (4)
5𝐼4 + 7𝐼5 = 14 (5)
Solution :
3 5 0 0 0 𝐼1 10
6 5 8 0 0 𝐼2 11
0 8 6 2 0 𝐼3 = 12
0 0 1 8 3 𝐼4 13
0 0 0 5 7 𝐼5 14
𝑐𝑇 = 5 8 2 3
𝑑𝑇 = 3 5 6 8 7
𝑎𝑇 = 6 8 1 5
𝑏𝑇 = 10 11 12 13 14
45
𝑐𝑇 = 5 8 2 3
𝑑𝑇 = 3 5 6 8 7
𝑎𝑇 = 6 8 1 5
𝑏𝑇 = 10 11 12 13 14
6
𝑑2′ = 5 − ( )(5) = −5
3
8
𝑑3′ = 6 − 8 = 18.8
−5
1
𝑑4′ = 8 − 2 = 7.89362
18.8
5
𝑑5′ = 7 − (3) = 5.09973
7.89362
46
𝑐𝑇 = 5 8 2 3
𝑑𝑇 = 3 5 6 8 7
𝑎𝑇 = 6 8 1 5
𝑏𝑇 = 10 11 12 13 14
′
6
𝑑2 = 5 − ( )(5) = −5
3
8
𝑑3′ = 6 − 8 = 18.8
−5
′
1
𝑑4 = 8 − 2 = 7.89362
18.8
′ 5
𝑑5 = 7 − (3) = 5.09973
7.89362
′
6
𝑏2 = 11 − 10 = −9
3
8
𝑏3′ = 12 − −9 = −2.4
−5
1
𝑏4′ = 13 − −2.4 = 13.12766
18.8
5
𝑏5′ = 14 − (13.12766) = 5.68464
7.89362 47
𝑐𝑇 = 5 8 2 3
𝑑 𝑇 ′ = 3 −5 18.8 7.89362 5.09973
′
𝑏𝑇 = 10 −9 −2.4 13.12766 5.68464
48
𝑐𝑇 = 5 8 2 3
𝑑 𝑇 ′ = 3 −5 18.8 7.89362 5.09973
′
𝑏𝑇 = 10 −9 −2.4 13.12766 5.68464
Hence, the new matrix will be,
3 5 0 0 0 𝐼1 10
0 −5 8 0 0 𝐼2 −9
0 0 18.8 2 0 𝐼3 = −2.4
0 0 0 7.89362 3 𝐼4 13.12766
0 0 0 0 5.09973 𝐼5 5.68464
49
𝑐𝑇 = 5 8 2 3
𝑑𝑇 ′ = 3 −5 18.8 7.89362 5.09973
′
𝑏𝑇 = 10 −9 −2.4 13.12766 5.68464
Hence, the new matrix will be,
3 5 0 0 0 𝐼1 10
0 −5 8 0 0 𝐼2 −9
0 0 18.8 2 0 𝐼3 = −2.4
0 0 0 7.89362 3 𝐼4 13.12766
0 0 0 0 5.09973 𝐼5 5.68464
Using back substitution to determine the unknowns,
5.68464
𝐼5 = = 1.11469 𝐴
5.09973
13.12766 − (3𝑥1.11469)
𝐼4 = = 1.23943 𝐴
7.89362
−2.4 − (2𝑥1.23943)
𝐼3 = = −0.25951 𝐴
18.8
−9 − (8𝑥 − 0.25951)
𝐼2 = = 1.384778 𝐴
−5
10 − (5𝑥1.38478)
𝐼1 = = 1.02537 𝐴
3
50
Gauss-Jordan Method
The method reduces the general system of equations AX=B to IX=B where I
is an identity matrix.
It has the same problems as Naive Gaussian elimination and can be modified
to do partial scaled pivoting.
52
Example Problem:
5. Use Gauss Jordan Elimination to solve:
3𝑥1 − 0.1𝑥2 − 0.2𝑥3 = 7.85 (1)
0.1𝑥1 + 7𝑥2 − 0.3𝑥3 = −19.3 (2)
0.3𝑥1 − 0.2𝑥2 + 10𝑥3 = 71.4 (3)
53
Example Problem:
5. Use Gauss Jordan Elimination to solve:
3𝑥1 − 0.1𝑥2 − 0.2𝑥3 = 7.85 (1)
0.1𝑥1 + 7𝑥2 − 0.3𝑥3 = −19.3 (2)
0.3𝑥1 − 0.2𝑥2 + 10𝑥3 = 71.4 (3)
Solution:
Using forward elimination , multiply equation (1) by 0.1/3 and subtract from eq. (2):
𝑎21
𝑒𝑞 2 − 𝑒𝑞(1)
𝑎11
0.1
(0.1𝑥1 + 7𝑥2 − 0.3𝑥3 + 19.3) − ( 3 )(3𝑥1 − 0.1𝑥2 − 0.2𝑥3 − 7.85) = 7.00333𝑥2 − 0.293333𝑥3 + 19.5617
55
Hence the equation will be:
3𝑥1 − 0.1𝑥2 − 0.2𝑥3 = 7.85 (4)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(5)
−0.1900𝑥2 + 10.0200𝑥3 = 70.6150 (6)
To complete the forward elimination, x2 must be completely removed from eq. (6). To accomplish this multiply
eq. (5) by -0.19000/7.00333 and subtract from eq. (6)
𝑎31 ′
𝑒𝑞 6 − 𝑒𝑞(5)
𝑎21 ′
−0.1900
−0.1900𝑥2 + 10.0200𝑥3 − 70.6150 − 7.00333𝑥2 − 0.293333𝑥3 + 19.5617 = 10.0120𝑥3 − 70.0843
7.00333
56
Hence the equation will be:
3𝑥1 − 0.1𝑥2 − 0.2𝑥3 = 7.85 (4)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(5)
−0.1900𝑥2 + 10.0200𝑥3 = 70.6150 (6)
To complete the forward elimination, x2 must be completely removed from eq. (6). To accomplish this multiply
eq. (5) by -0.19000/7.00333 and subtract from eq. (6)
𝑎31 ′
𝑒𝑞 6 − 𝑒𝑞(5)
𝑎21 ′
−0.1900
−0.1900𝑥2 + 10.0200𝑥3 − 70.6150 − 7.00333𝑥2 − 0.293333𝑥3 + 19.5617 = 10.0120𝑥3 − 70.0843
7.00333
Thus, the set of equation will be:
3𝑥1 − 0.1𝑥2 − 0.2𝑥3 = 7.85 (7)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(8)
10.0120𝑥3 = 70.0843 (9)
57
Hence the equation will be:
3𝑥1 − 0.1𝑥2 − 0.2𝑥3 = 7.85 (4)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(5)
−0.1900𝑥2 + 10.0200𝑥3 = 70.6150 (6)
To complete the forward elimination, x2 must be completely removed from eq. (6). To accomplish this multiply
eq. (5) by -0.19000/7.00333 and subtract from eq. (6)
𝑎31 ′
𝑒𝑞 6 − 𝑒𝑞(5)
𝑎21 ′
−0.1900
−0.1900𝑥2 + 10.0200𝑥3 − 70.6150 − 7.00333𝑥2 − 0.293333𝑥3 + 19.5617 = 10.0120𝑥3 − 70.0843
7.00333
Thus, the set of equation will be:
3𝑥1 − 0.1𝑥2 − 0.2𝑥3 = 7.85 (7)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(8)
10.0120𝑥3 = 70.0843 (9)
Eliminate x2 from eq. (7) multiplying eq. (8) by 0.1/7.00333 and subtract from eq. (7)
𝑎12 ′
𝑒𝑞 7 − 𝑒𝑞(5)
𝑎22 ′
−0.1
3𝑥1 − 0.1𝑥2 − 0.2𝑥3 − 7.85 − 7.00333𝑥2 − 0.293333𝑥3 + 19.5617 = 3𝑥1 − 0.204188𝑥3 − 7.5678
7.00333
58
Hence, the new equation will be:
3𝑥1 − 0.19581𝑥3 = 8.12932 (10)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(11)
10.0120𝑥3 = 70.0843 (12)
59
Hence, the new equation will be:
3𝑥1 − 0.19581𝑥3 = 8.12932 (10)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(11)
10.0120𝑥3 = 70.0843 (12)
Eliminate x3 from eq. (10) multiplying eq. (12) by -0.19581/10.012 and subtract from eq. (12)
𝑎13 ′′
𝑒𝑞 10 − 𝑒𝑞(12)
𝑎33 ′′
−0.19581
3𝑥1 − 0.19581𝑥3 − 8.12932 − 10.0120𝑥3 − 70.0843 = 3𝑥1 − 9
10.012
60
Hence, the new equation will be:
3𝑥1 − 0.19581𝑥3 = 8.12932 (10)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(11)
10.0120𝑥3 = 70.0843 (12)
Eliminate x3 from eq. (10) multiplying eq. (12) by -0.19581/10.012 and subtract from eq. (12)
𝑎13 ′′
𝑒𝑞 10 − 𝑒𝑞(12)
𝑎33 ′′
−0.19581
3𝑥1 − 0.19581𝑥3 − 8.12932 − 10.0120𝑥3 − 70.0843 = 3𝑥1 − 9
10.012
Hence, the new equation will be:
3𝑥1 = 9 (13)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(14)
10.0120𝑥3 = 70.0843 (15)
61
Hence, the new equation will be:
3𝑥1 − 0.19581𝑥3 = 8.12932 (10)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(11)
10.0120𝑥3 = 70.0843 (12)
Eliminate x3 from eq. (10) multiplying eq. (12) by -0.19581/10.012 and subtract from eq. (12)
𝑎13 ′′
𝑒𝑞 10 − 𝑒𝑞(12)
𝑎33 ′′
−0.19581
3𝑥1 − 0.19581𝑥3 − 8.12932 − 10.0120𝑥3 − 70.0843 = 3𝑥1 − 9
10.012
Hence, the new equation will be:
3𝑥1 = 9 (13)
7.00333𝑥2 − 0.293333𝑥3 = −19.5617(14)
10.0120𝑥3 = 70.0843 (15)
Eliminate x3 from eq. (14) multiplying eq. (15) by -0.293333/10.0120 and subtract from eq. (14)
𝑎23 ′′′
𝑒𝑞 14 − 𝑒𝑞(15)
𝑎33 ′′′
−0.293333
7.00333𝑥2 − 0.293333𝑥3 + 19.5617 − 10.0120𝑥3 − 70.0843 = 7.00333𝑥2 + 17.50836
10.0120
62
Hence, the new equation will be:
3𝑥1 = 9(16)
7.00333𝑥2 = −17.50836(17)
10.0120𝑥3 = 70.0843 (18)
63
Hence, the new equation will be:
3𝑥1 = 9(16)
7.00333𝑥2 = −17.50836(17)
10.0120𝑥3 = 70.0843 (18)
Divide eq. (16), eq. (17) and eq. (18) with 3, 7.00333 and 10.012 respectively to determine the identity matrix.
Hence, the new matrix will be,
1 0 0 𝑥1 3
0 1 0 𝑥2 = −2.5
0 0 1 𝑥3 7.00003
The solution matrix will be:
𝑥1 3
𝑥2 = −2.5
𝑥3 7
64
Example Problem:
6. Use Gauss Jordan Elimination to solve:
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 = 16 (1)
12𝑥1 − 8𝑥2 + 6𝑥3 + 10𝑥4 = 26 (2)
3𝑥1 − 13𝑥2 + 9𝑥3 + 3𝑥4 = −19 (3)
−6𝑥1 + 4𝑥2 + 𝑥3 − 18𝑥4 = −34 (4)
65
Example Problem:
6. Use Gauss Jordan Elimination to solve:
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 = 16 (1)
12𝑥1 − 8𝑥2 + 6𝑥3 + 10𝑥4 = 26 (2)
3𝑥1 − 13𝑥2 + 9𝑥3 + 3𝑥4 = −19 (3)
−6𝑥1 + 4𝑥2 + 𝑥3 − 18𝑥4 = −34 (4)
Solution:
Using forward elimination , multiply equation (1) by 12/6 and subtract from eq. (2):
𝑎21
𝑒𝑞 2 − 𝑒𝑞(1)
𝑎11
(12𝑥1 − 8𝑥2 + 6𝑥3 + 10𝑥4 − 26) − (2)(6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 − 16 ) = −4𝑥2 + 2𝑥3 + 2𝑥4 + 6
Multiply eq (1) by 3/6 and subtract from eq (3):
𝑎31
𝑒𝑞 3 − 𝑒𝑞(1)
𝑎11
(3𝑥1 − 13𝑥2 + 9𝑥3 + 3𝑥4 + 19) − (1/2)(6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 − 16 ) = −12𝑥2 + 8𝑥3 + 𝑥4 + 27
Multiply eq (1) by -6/6 and subtract from eq (4):
𝑎41
𝑒𝑞 4 − 𝑒𝑞(1)
𝑎11 66
(−6𝑥1 + 4𝑥2 + 𝑥3 − 18𝑥4 + 34) − (−1)(6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 − 16 ) = 2𝑥2 + 3𝑥3 − 14𝑥4 + 18
Hence the equation will be:
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 = 16 (5)
−4𝑥2 + 2𝑥3 + 2𝑥4 = −6 (6)
−12𝑥2 + 8𝑥3 + 𝑥4 = −27 (7)
2𝑥2 + 3𝑥3 − 14𝑥4 = −18 (8)
67
Hence the equation will be:
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 = 16 (5)
−4𝑥2 + 2𝑥3 + 2𝑥4 = −6 (6)
−12𝑥2 + 8𝑥3 + 𝑥4 = −27 (7)
2𝑥2 + 3𝑥3 − 14𝑥4 = −18 (8)
Using forward elimination , multiply equation (6) by -12/-4 and subtract from eq. (7):
𝑎32 ′
𝑒𝑞 7 − 𝑒𝑞(6)
𝑎22 ′
(−12𝑥2 + 8𝑥3 + 𝑥4 + 27) − (3)(−4𝑥2 + 2𝑥3 + 2𝑥4 − 6 ) = 2𝑥3 − 5𝑥4 + 9
Multiply eq (6) by -2/4 and subtract from eq (8):
𝑎42 ′
𝑒𝑞 8 − 𝑒𝑞(6)
𝑎22 ′
(2𝑥2 + 3𝑥3 − 14𝑥4 + 18) − (−1/2)(−4𝑥2 + 2𝑥3 + 2𝑥4 − 6 ) = 4𝑥3 − 13𝑥4 + 21
68
Hence the equation will be:
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 = 16 (5)
−4𝑥2 + 2𝑥3 + 2𝑥4 = −6 (6)
−12𝑥2 + 8𝑥3 + 𝑥4 = −27 (7)
2𝑥2 + 3𝑥3 − 14𝑥4 = −18 (8)
Using forward elimination , multiply equation (6) by -12/-4 and subtract from eq. (7):
𝑎32 ′
𝑒𝑞 7 − 𝑒𝑞(6)
𝑎22 ′
(−12𝑥2 + 8𝑥3 + 𝑥4 + 27) − (3)(−4𝑥2 + 2𝑥3 + 2𝑥4 − 6 ) = 2𝑥3 − 5𝑥4 + 9
Multiply eq (6) by -2/4 and subtract from eq (8):
𝑎42 ′
𝑒𝑞 8 − 𝑒𝑞(6)
𝑎22 ′
(2𝑥2 + 3𝑥3 − 14𝑥4 + 18) − (−1/2)(−4𝑥2 + 2𝑥3 + 2𝑥4 − 6 ) = 4𝑥3 − 13𝑥4 + 21
Hence the equation will be:
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 = 16 (9)
−4𝑥2 + 2𝑥3 + 2𝑥4 = −6 (10)
2𝑥3 − 5𝑥4 = −9 (11)
4𝑥3 − 13𝑥4 = −21 12 69
Using forward elimination , multiply equation (11) by 4/2 and subtract from eq. (12):
𝑎43 ′′
𝑒𝑞 12 − 𝑒𝑞(11)
𝑎33 ′′
4𝑥3 − 13𝑥4 + 21 − 2 2𝑥3 − 5𝑥4 + 9 = −3𝑥4 + 3
70
Using forward elimination , multiply equation (11) by 4/2 and subtract from eq. (12):
𝑎43 ′′
𝑒𝑞 12 − 𝑒𝑞(11)
𝑎33 ′′
4𝑥3 − 13𝑥4 + 21 − 2 2𝑥3 − 5𝑥4 + 9 = −3𝑥4 + 3
Hence the equation will be:
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 = 16 (13)
−4𝑥2 + 2𝑥3 + 2𝑥4 = −6 (14)
2𝑥3 − 5𝑥4 = −9 (15)
−3𝑥4 = −3 (16)
71
Using forward elimination , multiply equation (11) by 4/2 and subtract from eq. (12):
𝑎43 ′′
𝑒𝑞 12 − 𝑒𝑞(11)
𝑎33 ′′
4𝑥3 − 13𝑥4 + 21 − 2 2𝑥3 − 5𝑥4 + 9 = −3𝑥4 + 3
Hence the equation will be:
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 = 16 (13)
−4𝑥2 + 2𝑥3 + 2𝑥4 = −6 (14)
2𝑥3 − 5𝑥4 = −9 (15)
−3𝑥4 = −3 (16)
To eliminate x2 from eq. (13) , multiply equation (14) by -2/-4 and subtract from eq. (13):
𝑎12 ′′′
𝑒𝑞 13 − 𝑒𝑞(14)
𝑎22 ′′′
1
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 − 16 − −4𝑥2 + 2𝑥3 + 2𝑥4 + 6 = 6𝑥1 + 𝑥3 + 3𝑥4 − 19
2
72
Using forward elimination , multiply equation (11) by 4/2 and subtract from eq. (12):
𝑎43 ′′
𝑒𝑞 12 − 𝑒𝑞(11)
𝑎33 ′′
4𝑥3 − 13𝑥4 + 21 − 2 2𝑥3 − 5𝑥4 + 9 = −3𝑥4 + 3
Hence the equation will be:
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 = 16 (13)
−4𝑥2 + 2𝑥3 + 2𝑥4 = −6 (14)
2𝑥3 − 5𝑥4 = −9 (15)
−3𝑥4 = −3 (16)
To eliminate x2 from eq. (13) , multiply equation (14) by -2/-4 and subtract from eq. (13):
𝑎12 ′′′
𝑒𝑞 13 − 𝑒𝑞(14)
𝑎22 ′′′
1
6𝑥1 − 2𝑥2 + 2𝑥3 + 4𝑥4 − 16 − −4𝑥2 + 2𝑥3 + 2𝑥4 + 6 = 6𝑥1 + 𝑥3 + 3𝑥4 − 19
2
74
To eliminate x3 from eq. (17) , multiply equation (19) by 1/2 and subtract from eq. (17):
𝑎13 ′′′′
𝑒𝑞 17 − 𝑒𝑞(19)
𝑎33 ′′′′
1
6𝑥1 + 𝑥3 + 3𝑥4 − 19 − 2𝑥3 − 5𝑥4 + 9 = 6𝑥1 + 5.5𝑥4 − 23.5
2
75
To eliminate x3 from eq. (17) , multiply equation (19) by 1/2 and subtract from eq. (17):
𝑎13 ′′′′
𝑒𝑞 17 − 𝑒𝑞(19)
𝑎33 ′′′′
1
6𝑥1 + 𝑥3 + 3𝑥4 − 19 − 2𝑥3 − 5𝑥4 + 9 = 6𝑥1 + 5.5𝑥4 − 23.5
2
76
Hence the new equation will be:
6𝑥1 = 18(25)
−4𝑥2 + 2𝑥3 + 2𝑥4 = −6 (26)
2𝑥3 − 5𝑥4 = −9 (27)
−3𝑥4 = −3 (28)
77
Hence the new equation will be:
6𝑥1 = 18(25)
−4𝑥2 + 2𝑥3 + 2𝑥4 = −6 (26)
2𝑥3 − 5𝑥4 = −9 (27)
−3𝑥4 = −3 (28)
To eliminate x3 from eq. (26) , multiply equation (27) by 2/2 and subtract from eq. (26):
𝑎23 ′′′′′′
𝑒𝑞 26 − 𝑒𝑞(27)
𝑎33 ′′′′′′
2
−4𝑥2 + 2𝑥3 + 2𝑥4 + 6 − 2𝑥3 − 5𝑥4 + 9 = −4𝑥2 + 7𝑥4 − 3
2
78
Hence the new equation will be:
6𝑥1 = 18(25)
−4𝑥2 + 2𝑥3 + 2𝑥4 = −6 (26)
2𝑥3 − 5𝑥4 = −9 (27)
−3𝑥4 = −3 (28)
To eliminate x3 from eq. (26) , multiply equation (27) by 2/2 and subtract from eq. (26):
𝑎23 ′′′′′′
𝑒𝑞 26 − 𝑒𝑞(27)
𝑎33 ′′′′′′
2
−4𝑥2 + 2𝑥3 + 2𝑥4 + 6 − 2𝑥3 − 5𝑥4 + 9 = −4𝑥2 + 7𝑥4 − 3
2
Hence the new equation will be:
6𝑥1 = 18(29)
−4𝑥2 + 7𝑥4 = 3(30)
2𝑥3 − 5𝑥4 = −9 (31)
−3𝑥4 = −3 (32)
79
To eliminate x4 from eq. (30) , multiply equation (32) by -7/3 and subtract from eq. (30):
𝑎24 ′′′′′′′
𝑒𝑞 30 − 𝑒𝑞(32)
𝑎44 ′′′′′′′
7
−4𝑥2 + 7𝑥4 − 3 − − −3𝑥4 + 3 = −4𝑥2 + 4
3
80
To eliminate x4 from eq. (30) , multiply equation (32) by -7/3 and subtract from eq. (30):
𝑎24 ′′′′′′′
𝑒𝑞 30 − 𝑒𝑞(32)
𝑎44 ′′′′′′′
7
−4𝑥2 + 7𝑥4 − 3 − − −3𝑥4 + 3 = −4𝑥2 + 4
3
Hence the new equation will be:
6𝑥1 = 18(33)
−4𝑥2 = −4(34)
2𝑥3 − 5𝑥4 = −9 (35)
−3𝑥4 = −3 (36)
81
To eliminate x4 from eq. (30) , multiply equation (32) by -7/3 and subtract from eq. (30):
𝑎24 ′′′′′′′
𝑒𝑞 30 − 𝑒𝑞(32)
𝑎44 ′′′′′′′
7
−4𝑥2 + 7𝑥4 − 3 − − −3𝑥4 + 3 = −4𝑥2 + 4
3
Hence the new equation will be:
6𝑥1 = 18(33)
−4𝑥2 = −4(34)
2𝑥3 − 5𝑥4 = −9 (35)
−3𝑥4 = −3 (36)
To eliminate x4 from eq. (35) , multiply equation (36) by 5/3 and subtract from eq. (35):
𝑎34 ′′′′′′′′
𝑒𝑞 35 − 𝑒𝑞(36)
𝑎44 ′′′′′′′′
5
2𝑥3 − 5𝑥4 + 9 − −3𝑥4 + 3 = 2𝑥2 + 4
3
82
To eliminate x4 from eq. (30) , multiply equation (32) by -7/3 and subtract from eq. (30):
𝑎24 ′′′′′′′
𝑒𝑞 30 − 𝑒𝑞(32)
𝑎44 ′′′′′′′
7
−4𝑥2 + 7𝑥4 − 3 − − −3𝑥4 + 3 = −4𝑥2 + 4
3
Hence the new equation will be:
6𝑥1 = 18(33)
−4𝑥2 = −4(34)
2𝑥3 − 5𝑥4 = −9 (35)
−3𝑥4 = −3 (36)
To eliminate x4 from eq. (35) , multiply equation (36) by 5/3 and subtract from eq. (35):
𝑎34 ′′′′′′′′
𝑒𝑞 35 − 𝑒𝑞(36)
𝑎44 ′′′′′′′′
5
2𝑥3 − 5𝑥4 + 9 − −3𝑥4 + 3 = 2𝑥2 + 4
3
Hence the new equation will be:
6𝑥1 = 18(37)
−4𝑥2 = −4(38)
83
2𝑥3 = −4 (39)
−3𝑥4 = −3 (40)
Hence the new equation will be:
6𝑥1 = 18(37)
−4𝑥2 = −4(38)
2𝑥3 = −4 (39)
−3𝑥4 = −3 (40)
84
Hence the new equation will be:
6𝑥1 = 18(37)
−4𝑥2 = −4(38)
2𝑥3 = −4 (39)
−3𝑥4 = −3 (40)
Dividing eq. (37) to (40) with 6,-4,2 and -3 respectively to determine the identity matrix will yield.
1 0 0 0 𝑥1 3
0 1 0 0 𝑥2 1
=
0 0 1 0 𝑥3 −2
0 0 0 1 𝑥4 1
The solution matrix will be:
𝑥1 3
𝑥2 1
𝑥3 =
−2
𝑥4 1
85