Numerical Analysis Chapter 4
Numerical Analysis Chapter 4
Greeting
Numerical Analysis
Solving Linear Systems of Equations
OL Say
3 LU Decompositions
4 Gauss-Jordan Elimination
8 Relaxation Techniques
a a ··· a1n x1 b
© 11 12 ª © ª © 1ª
a21 a22 · · · a2n ® x2 ® b2 ®
.
.. .. .. .. ®® .. ®® = .. ®®
. . . ® ® . ® .
«an1 an2 · · · ann ¬ «xn ¬ « bn ¬
or simply AX = B.
a a ··· a1n b1
© 11 12
a21 a22 · · · a2n b2 ®
ª
(A|B) = . .. .. .. .. ®®
.. . . . . ®
a a
« n1 n2 · · · ann bn ¬
4 In the first few sections, we discuss about direct methods for
solving the system. The three popular methods are listed below
Method Initial form Final form
Gauss elimination AX = B UX = C
LU decomposition AX = B LUX = B
Gauss-Jordan elimination AX = B IX = C
OL Say (ITC) Numerical Analysis September 21, 2023 4 / 54
1. Linear Systems of Equations
l 0 0 ··· 0
© 11
l21 l22 0 · · · 0 ®
ª
Example 1
Represent the linear system
x1 − x2 + 2x3 − x4 = −8,
x1 − x2
+ 2x3 − x4 = −8,
x1 + x2
+ x3 = −2,
x1 − x2
+ 4x3 + 3x4 = 4,
as an augmented matrix and use Gaussian Elimination to find its
solution.
.. .. .. .. .. .. ..
. . . . . . .
..
. ak,k ak,k+1 ak,k+2 ··· ak,n
i=k+1 ak+1,k ak+1,k+1 ak+1,k+2 ··· ak+1,n
i = k + 2 (0) ak+2,k ak+2,k+1 ak+2,k+2 ··· ak+2,n
.. .. .. .. .. ..
. . . . . .
i=n an,k an,k+1 an,k+2 ··· an,n
j=k j = k +1 j = k +2 ··· j=n
4 R3 ← R3 − l32 R2
u11 u12 u13
A2 = 0 u22 u23 ®
© ª
« 0 0 u33 ¬
Example 2
Use Doolittle’s decomposition method to solve the equations
AX = B, where
1 4 1 7
A= 1 6 −1 ® , B = 13 ®
© ª © ª
« 2 −1 2 ¬ « 5 ¬
1 Decompose A into LU by Gaussian Elimination method.
2 Solve LY = B for Y by Forward Substitution method where Y = UX.
3 Solve UX = Y for X by Backward Substitution method.
OL Say (ITC) Numerical Analysis September 21, 2023 11 / 54
3.1 Doolittle LU Decomposition
4 OUTPUT L and U
Example 4
2 1 0
A symmetric matrix A = 1 2 1 ® is positive definite because
© ª
« 0 1 2 ¬
2 1 0 x1
X T AX = (x1 , x2 , x3 ) 1 2 1 ® x2 ®
© ª© ª
« 0 1 2 ¬ « x3 ¬
= x1 + (x1 + x2 )2 + (x2 + x3 )2 + x32 > 0, for all X ≠ 0.
2
a a ··· a1k
© 11 12
a21 a22 · · · a2k
ª
®
Ak = . .. .. .. ®
.. . . . ®
®
a
« k1 a k2 · · · akk ¬
for some 1 ≤ k ≤ n.
Theorem 6
Example 7
2 1 0
A symmetric matrix A = 1 2 1 ® is positive definite because
© ª
« 0 1 2 ¬
=2>0
A1 = det 2
2 1
A2 = det =3>0
1 2
2 1 0
A3 = det 1 2 1 ® = 4 > 0.
© ª
« 0 1 2 ¬
Theorem 8
1 Second row
d1 l21 = a21 ⇒ l21 = a21 /d1
2 2
d1 l21 + d2 = a22 ⇒ d2 = a22 − d1 l21
2 Third row
d1 l31 = a31 ⇒ l31 = a31 /d1
d1 l31 l21 + d2 l32 = a32 ⇒ l32 = (a32 − d1 l31 l21 )/d2
2 2 2 2
d1 l31 + d2 l32 + d3 = a33 ⇒ d3 = a33 − d1 l31 − d2 l32
3 Fourth row
d1 l41 = a41 ⇒ l41 = a41 /d1
d1 l41 l21 + d2 l42 = a42 ⇒ l42 = (a42 − d1 l41 l21 )/d2
d1 l41 l31 + d2 l42 l32 + d3 l43 = a43 ⇒ l43 = (a42 − d1 l41 l31 − d2 l42 l32 )/d3
2 2 2 2 2 2
d1 l41 + d2 l42 + d3 l43 + d4 = a44 ⇒ d4 = a44 − d1 l41 − d2 l42 − d3 l43
OL Say (ITC) Numerical Analysis September 21, 2023 18 / 54
3.2 Doolittle LDLt Decomposition
l 0 0 0 l l l l a (sym)
© 11 ª © 11 21 31 41 ª © 11
l21 l22 0 0 ® 0 l22 l32 l42 ® a21 a22
ª
®=
®
l31 l32 l33 0 ® 0 0 l33 l43 ® a31 a32 a33
® ®
®
«l41 l42 l43 l44 ¬ « 0 0 0 l44 ¬ «a41 a42 a43 a44 ¬
2 After completing the matrix multiplication on the left-hand side,
equate the elements in each row
2 √
3 First row l11 = a11 ⇒ l11 = a11
4 Second row
5 Third row
6 Fourth row
Example 11
Use Cholesky’s decomposition method to solve the equations
AX = B, where
4 −2 2 8
A = −2 2 −4 ® , B = 0 ®
© ª © ª
« 2 −4 11 ¬ « −9 ¬
d1 e1 0 0 0 ··· 0 d1 e1 f1 0 0 ··· 0
© c1 d2 e2 0 0 ··· 0 ª ©c1 d2 e2 f2 0 ··· 0 ª
® b1 c2 d3 e3 f3 ··· 0
®
···
0 c2 d3 e3 0 0 ®
0 0 c3 d4 e4 ··· 0
® .. .. ®
.
® 0 b2 c3 d4 e4 .
..
®, ®
.. ..
®
.
®
0 0 0 c4 d5 . ® 0 0 b3 c4 d5 .
®
fn−2 ®
. .. .. .. .. .. ®
.. en−1 ® ... .. .. .. .. .. ®
. . . . . . . .
. . en−1 ®
«0 0 0 0 ··· cn−1 dn ¬ ···
«0 0 0 bn−2 cn−1 dn ¬
1 0 0 0 0 ··· 0 d1 e1 0 0 0 ··· 0
1 1 0 0 0 ··· ···
©c 0ª® © 0 d2 e2 0 0 0ª
®
0 c 1 0 0 ··· 0®® 0 0 d3 e3 0 ··· 0®
2 ®
0 0 c3 1 0 · · · 0®® 0 0 0 d4 e4 ··· 0®
, ®
.. .. ® .. ..
®
0 0 0 c4 1 . . ®® 0 0 0 0 d5 . .
®
.. .. .. .. . . ® . .. .. .. . .
®
.. ..
. . 0® .. . .
®
. . . . . . . en−1 ®
« 0 0 0 0 · · · c n−1 1¬ « 0 0 0 0 · · · 0 dn ¬
1 −2 0 0
A = 2 −2 3 ® , B = −1 ®
© ª © ª
« 0 6 7 ¬ « −1 ¬
« 0 0 0 · · · fn−2 en−1 dn ¬
.. .. .. .. .. .. .. ..
© . . . . . . . . ª
··· 0 dk ek fk 0 0 0 ··· ®
®
··· 0 ek dk+1 ek+1 fk+1 0 0 ··· ®
A → ®
··· 0 fk ek+1 dk+2 ek+2 fk+2 0 ··· ®
®
··· 0 0 fk+1 ek+2 dk+3 ek+3 fk+3 ··· ®
.. .. .. .. .. .. ..
®
..
« . . . . . . . . ¬
6 The elements ek and fk below the pivot row (the k-th row) are
eliminated by the operations
Rk+1 ← Rk+1 − 𝜆1 Rk , 𝜆1 = ek /dk
Rk+2 ← Rk+2 − 𝜆2 Rk , 𝜆2 = fk /dk
7 The only terms (other than those being eliminated) that are
changed by the operations are
dk+1 ← dk+1 − 𝜆1 ek , 𝜆1 = ek /dk
ek+1 ← dk+1 − 𝜆1 fk , 𝜆1 = ek /dk
dk+2 ← dk+2 − 𝜆2 fk , 𝜆2 = fk /dk
8 Storage of the multipliers in the upper triangular portion of the
matrix results in
ek ← 𝜆1 = ek /dk
fk ← 𝜆2 = fk /dk
OL Say (ITC) Numerical Analysis September 21, 2023 33 / 54
5.2 LU Decomposition for Symmetric Pentadiagonal Matrix
«0 0 0 ··· 0 en−1 dn ¬
10 One last step
𝜆1 ← en−1 /dn−1
dn ← dn − 𝜆1 en−1
en−1 ← 𝜆1 .
OL Say (ITC) Numerical Analysis September 21, 2023 34 / 54
5.2 LU Decomposition for Symmetric Pentadiagonal Matrix
1 0 0 0 0 ··· 0 b1
©
e1 1 0 0 0 ··· 0 b2 ª
®
f1 e2 1 0 0 ··· 0 b3 ®
®
.. .. ®
(L|B) =
0 f2 e3 1 0 . . b4 ®
®
.. .
0 ..
®
0 0 f3 e4 1 . ®
.. .. .. .. .. ..
®
. . . . . .
0 bn−1
®
®
« 0 0 0 ··· fn−2 en−1 1 bn ¬
y1 = b1
y2 = b2 − e1 y1
..
.
yk = bk − ek−1 yk−1 − fk−2 yk−2 , k = 3, 4, ... , n
d1 d1 e1 d1 f1 0 0 ··· 0 y1
©
0 d2 d2 e2 d2 f2 0 ··· 0 y2 ª
®
0 0 d3 d3 e3 d3 f3 ··· 0 y3 ®
®
.. .. ®
(U|Y) = 0 0 0 d4 d4 f4 . . y4 ®
.. .. .. ..
®
.. .. ..
. . .
®
. . . dn−2 fn−2 . ®
®
0 0 0 ··· 0 dn−1 dn−1 en−1 yn−1 ®
« 0 0 0 ··· 0 0 dn yn ¬
xn = yn /dn
xn−1 = yn−1 /dn−1 − en−1 xn
..
.
xk = yk /dk − ek xk+1 − fk xk+2 , k = n − 2, n − 3, ... , 1.
3 6 3 0
A = 6 14 4 ® and B = −2 ®
© ª © ª
« 3 4 9 ¬ « 6 ¬
Example 15
1 4 −2 3 −1 1
A= 2 0 −3 ® , B = 1 4 −2 ®
© ª © ª
« 3 −1 1 ¬ « 2 0 −3 ¬
Example 16
Employ Gauss elimination with scaled row pivoting to solve the
equations AX = B, where
2 −3 4 −2 9
−2 4 1 −3 ® −27 ®
© ª © ª
A= ®,B = ®.
5 −4 3 −2 ® 17 ®
« 3 2 −4 2 ¬ « 4 ¬
(k)
For each k ≥ 1, generate the components xi of x(k) from the
components of x(k−1) by
n
(k) bi Õ aij (k−1)
xi = − x , i = 1, 2, ... , n.
aii aii j
j=1
j≠i
b1 a12 a13
x1 = −
x2 − x3
a11 a11 a11
b2 a21 a23
x =
2 − x1 − x3
a22 a22 a22
b3 a31 a32
x3 = − x2 − x3
a33 a33 a33
Jacobi Iteration is defined to be
(k) b1 a12 (k−1) a13 (k−1)
x1 = − x − x
a a11 2 a11 3
11
b2 a21 a23 (k−1)
(k) (k−1)
x = − x − x
2 a22 a22 1 a22 3
b a a32 (k−1)
(k) 3 31 (k−1)
x3 = − x − x
a33 a33 2 a33 3
i−1 n
(k) bi Õ aij (k) Õ aij (k−1)
xi = − x − x , i = 1, 2, ... , n.
aii aii j aii j
j=1 j=i+1
Example 19
2 −1 2 3
A = 4 −2 2 ® , B = 4 ®
© ª © ª
« 3 −1 1 ¬ « 4 ¬
Theorem 21
n o∞
For any X (0) ∈ Rn , the sequence X (k) defined by
k=0
X (k) = TX (k−1) + C, for each k ≥ 1, converges to the unique solution
of X = TX + C if and only if 𝜌(T) < 1.
Theorem 22 (Kahan)
Theorem 23 (Ostrowski-Reich)
Theorem 24
If A is positive definite and tridiagonal, then 𝜌(TG ) = [𝜌(TJ )]2 < 1, and
the optimal choice of 𝜔 for the Relaxation method is
2
𝜔= p ,
1 + 1 − [𝜌(TJ )]2
Example 25 (Relaxation)
Consider an equation AX = B with
4 3 0 24
a= 3 4 −1 ® , b = 30 ® .
© ª © ª
« 0 −1 4 ¬ « −24 ¬
1 Show that A is positive definite (|Ak | > 0, all its leading principle
submatrices has positive determinant.)
2 Split A = D − L − U and compute TJ = D−1 (L + U).
3 Find all eigenvalues of TJ , then determine the spectral radius
𝜌(TJ ) of Jacobi matrix TJ and deduce the optimal value of
Relaxation factor 𝜔.
4 Use computer program to solve the equation using Relaxation
method with initial guess X (0) = (1, 1, 1)T .
OL Say (ITC) Numerical Analysis September 21, 2023 54 / 54