Professional Documents
Culture Documents
Unit 3 (Systems of Linear Equations)
Unit 3 (Systems of Linear Equations)
Unit-3
(Systems of Linear Equations)
Dr. Muhammad Majid Gulzar (CIE-KFUPM)
Contents (Unit-3):
1) Naive Gauss Elimination (Sec 9.2)
Back Substitution: Solve the system starting from the last variable.
This basic approach can be extended to large sets of equations by developing a systematic scheme or
algorithm to eliminate unknowns and to back-substitute. Gauss elimination is the most basic of these
schemes.
𝑎𝑎11 𝑎𝑎12 𝑎𝑎13 𝑥𝑥1 𝑏𝑏1 𝑎𝑎11 𝑎𝑎12 𝑎𝑎13 𝑥𝑥1 𝑏𝑏1
𝑎𝑎21 𝑎𝑎22 𝑎𝑎23 𝑥𝑥2 = 𝑏𝑏2 ⇒ 0 𝑎𝑎22 ′ 𝑎𝑎23 ′ 𝑥𝑥2 = 𝑏𝑏2 ′
𝑎𝑎31 𝑎𝑎32 𝑎𝑎33 𝑥𝑥3 𝑏𝑏3 0 0 𝑎𝑎33 ′ 𝑥𝑥3 𝑏𝑏3 ′
0.1
𝑅𝑅2 − 𝑅𝑅
3 1
0.3
𝑅𝑅3 − 𝑅𝑅
3 1
0.190000
𝑅𝑅3 + 𝑅𝑅
7.00333 1
Verification
6 −2 2 4 𝑥𝑥1 16
12 −8 6 10 𝑥𝑥2 26
𝑥𝑥3 =
3 −13 9 3 −19
−6 4 1 −18 𝑥𝑥4 −34
Forward Elimination
Eliminate 𝑥𝑥1 from equations 2,3,4 Eliminate 𝑥𝑥2 from equations 3,4 Eliminate 𝑥𝑥3 from equations 4
6 −2 2 4 𝑥𝑥1 16
0 −4 2 2 𝑥𝑥2 −6
𝑥𝑥3 =
0 0 2 −5 −9
0 0 0 −3 𝑥𝑥4 −3
Backward Substitution
−3 −9 + 5
𝑥𝑥4 = = 𝟏𝟏 𝑥𝑥3 = = −𝟐𝟐
−3 2
0 1 𝑥𝑥1 1
=
The normalization of the first row would involve division by 0. 1 1 𝑥𝑥2 2
10−10 1 𝑥𝑥1 = 1
Problems also can arise when a coefficient is very close to 0. 1 1 𝑥𝑥2 2
Solution: Pivoting
3) Ill-Conditioned Systems
A small changes in coefficients result in large changes in the solution.
An alternative interpretation of ill-conditioning is that a wide range of answers can
approximately satisfy the equations.
As round-off errors can induce small changes in the coefficients, these artificial changes can
lead to large solution errors for ill-conditioned systems.
Solution: Use more significant figures, Pivoting & Scaling
Reduced Matrix has one or multiple zero Reduced Matrix has one or multiple zero
Reduced Matrix has no zero rows
rows corresponding 𝐵𝐵 elements ≠ 0 rows corresponding 𝐵𝐵 elements = 0
1 2 1 1 2 2 1 2 2
𝑋𝑋 = 𝑋𝑋 = 𝑋𝑋 =
3 4 2 2 4 3 2 4 4
1 2 1 1 2 2 1 2 2
𝑋𝑋 = 𝑋𝑋 = 𝑋𝑋 =
0 −2 −1 0 0 −1 0 0 0
The rows can then be switched so that the largest element is the pivot element.
2) Scaling
Scaling is used in minimizing round-off errors for cases where some of the equations in a
system have much larger coefficients than others.
1
𝑅𝑅
0.0003 1
𝑅𝑅2 − 𝑅𝑅1
Note: 𝑥𝑥1 is highly dependent on the number of significant figures because, we are subtracting two almost-equal numbers.
𝑅𝑅1 ↔ 𝑅𝑅2
0.0003
𝑅𝑅2 − 𝑅𝑅1
2.9997𝑥𝑥2 = 1.9998 1
The rows can then be switched so that the largest element is the pivot element.
2) Scaling
Scaling is used in minimizing round-off errors for cases where some of the equations in a
system have much larger coefficients than others.
1
𝑅𝑅2 − 𝑅𝑅1
2
Pivoting
0.00002
𝑅𝑅2 − 𝑅𝑅1
1
Pivoting
2
𝑅𝑅2 − 𝑅𝑅1
1
Note: For this case with Pivoting & without Scaling also leads to the correct answer.
The method reduced the general system of equations 𝐴𝐴𝐴𝐴 = 𝐵𝐵 to 𝐼𝐼𝐼𝐼 = 𝐵𝐵 where 𝐼𝐼 is an
identity matrix.
The elimination step results in an identity matrix rather than a triangular matrix.
It has the same problems as Naive Gaussian elimination and can be modified to do
partial scaled pivoting.
1
𝑅𝑅
3 1
1
𝑅𝑅
10.01200 3
Needs less storage (4𝑛𝑛 − 2 compared to 𝑛𝑛2 + 𝑛𝑛 for the general case)
1
𝑎𝑎𝑖𝑖−1 𝑥𝑥𝑖𝑖 = 𝑏𝑏 − 𝑐𝑐𝑖𝑖 𝑥𝑥𝑖𝑖+1 for 𝑖𝑖 = 𝑛𝑛 − 1, 𝑛𝑛 − 2, . . . , 1
𝑏𝑏𝑖𝑖 ← 𝑏𝑏𝑖𝑖 − 𝑏𝑏 2 ≤ 𝑖𝑖 ≤ 𝑛𝑛 𝑑𝑑𝑖𝑖 𝑖𝑖
𝑑𝑑𝑖𝑖−1 𝑖𝑖−1
5 2 𝑥𝑥1 12 5 1 2 12
1 5 2 𝑥𝑥2 9 5 1 2 9
𝑥𝑥3 = ⇒ 𝐷𝐷 = , 𝐴𝐴 = , 𝐶𝐶 = , 𝐵𝐵 =
1 5 2 8 5 1 2 8
1 5 𝑥𝑥4 6 5 6
1
𝑎𝑎𝑖𝑖−1 𝑥𝑥𝑖𝑖 = 𝑏𝑏 − 𝑐𝑐𝑖𝑖 𝑥𝑥𝑖𝑖+1 for 𝑖𝑖 = 𝑛𝑛 − 1, 𝑛𝑛 − 2, . . . , 1
𝑏𝑏𝑖𝑖 ← 𝑏𝑏𝑖𝑖 − 𝑏𝑏 2 ≤ 𝑖𝑖 ≤ 𝑛𝑛 𝑑𝑑𝑖𝑖 𝑖𝑖
𝑑𝑑𝑖𝑖−1 𝑖𝑖−1
5 2 𝑥𝑥1 12 5 1 2 12
1 5 2 𝑥𝑥2 9 5 1 2 9
𝑥𝑥3 = ⇒ 𝐷𝐷 = , 𝐴𝐴 = , 𝐶𝐶 = , 𝐵𝐵 =
1 5 2 8 5 1 2 8
1 5 𝑥𝑥4 6 5 6
Forward Elimination
𝑎𝑎1 1×2 𝑎𝑎1 1 × 12
𝑑𝑑2 = 𝑑𝑑2 − 𝑐𝑐 = 5 − = 𝟒𝟒. 𝟔𝟔 𝑏𝑏2 = 𝑏𝑏2 − 𝑏𝑏 = 9 − = 𝟔𝟔. 𝟔𝟔
𝑑𝑑1 1 5 𝑑𝑑1 1 5
Backward substitution
𝑏𝑏4 4.5619
𝑥𝑥4 = = = 𝟏𝟏
𝑑𝑑4 4.5619
1
𝑎𝑎𝑖𝑖−1 𝑥𝑥𝑖𝑖 = 𝑏𝑏 − 𝑐𝑐𝑖𝑖 𝑥𝑥𝑖𝑖+1 for 𝑖𝑖 = 𝑛𝑛 − 1, 𝑛𝑛 − 2, . . . , 1
𝑏𝑏𝑖𝑖 ← 𝑏𝑏𝑖𝑖 − 𝑏𝑏 2 ≤ 𝑖𝑖 ≤ 𝑛𝑛 𝑑𝑑𝑖𝑖 𝑖𝑖
𝑑𝑑𝑖𝑖−1 𝑖𝑖−1
1.721
1.211
Answer: 𝐷𝐷𝑇𝑇 = 10 9.8 9.796 9.796 𝐵𝐵𝑇𝑇 = 16 11.2 6.286 3.283 𝑥𝑥 =
0.676
0.335
Dr. Muhammad Majid Gulzar (CIE-KFUPM)