Numerical Methods: LU Decomposition
Numerical Methods: LU Decomposition
Numerical Methods: LU Decomposition
NUMERICAL METHODS
LU decomposition
1
LU decomposition
Introduction
Consider the system of equations
Ax=b
Also known as the decomposition method or the factorization method.
Coefficient matrix A is decomposed into product of lower triangular and upper
triangular matrices.
We can write matrix A as
A=LU
where L is lower triangular matrix and U is upper triangular matrix given as
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 2
LU Decomposition
L and U Matrices
l11 0 0 . . . 0 u11 u12 u13 . . . u1n
l21 l22 0 . . . 0 0 u22 u23 . . . u2n
L = l31 l32 l33 . . . 0 , U = 0 0 u33 . . . u3n
.. ..
. .
ln1 ln2 ln3 . . . lnn 0 0 0 . . . unn
Usual matrix multiplication is used to multiply matrices L and U.
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 3
LU decomposition
Algorithm
Comparing elements of resulting matrix LU with elements of A. We get
li1 u1j + li2 u2j + . . . + lin unj = aij , j = 1, · · · , n (1)
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 4
LU decomposition
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 5
LU decomposition
Crout’s method
i−1
X
uij = (aij − lik ukj )/lii , i < j (2)
k =1
uii = 1.
The first column of matrix L is identical with first column of matrix A. i.e.
li1 = ai1 , i = 1, · · · , n. (3)
Also, u1j = a1j /l11 , j = 2, · · · , n. (4)
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 6
LU decomposition
Crout’s method
The first column of L and first row of U have been determined.
Now, we proceed to find second column of L and second row of U.
li2 = ai2 − li1 u12 , i = 2, · · · , n
u2j = (a2j − l21 u1j )/l22 , j = 3, · · · , n. (5)
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 7
LU decomposition
Crout’s Method
Next, we will find the third column of L and third row of U.
Elements of A are to be find out by comparing with elements of matrix LU.
For relevant indices i and j, the elements are computed in order
li1 , u1j ; li2 , u2j ; li3 , u3j ; · · · ; li,n−1 , un−1,j ; lnn
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 8
LU decomposition
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 9
LU decomposition
Example: Crout’s method
First column gives
l11 = 1; l21 = 3; l31 = 2
First row gives
u12 = 2; u13 = 4
Second column gives
l22 = 2; l32 = 2
Second row gives
u23 = 1
Third column/row gives
l33 = 3
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 10
LU decomposition
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 11
LU decomposition
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 12
LU decomposition
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 13
LU decomposition
LUx=b. (6)
Lz=b (8)
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 14
Linear System
Example
Consider the system of equations
1 2 4 x1 4
3 8 14 x2 = 12
2 6 13 x3 11
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 15
Triangularization Method
Example
This system can be written as in triangular matrices form
1 0 0 1 2 4 x1 4
3 1 0 0 2 2 x2 = 12
2 1 1 0 0 3 x3 11
Let
1 2 4 x1 z1
0 2 2 x2 = z2
0 0 3 x3 z3
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 16
Triangularization Method
Example cont...
1 0 0 z1 4
3 1 0 z2 = 12
2 1 1 z3 11
Using forward substitution, we get z1 = 4; z2 = 0; z3 = 3. Now, solving Lx = z
using back substitution
1 2 4 x1 4
0 2 2 x2 = 0
0 0 3 x3 3
We get x1 = 2; x2 = −1; x3 = 1.
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 17
LU Decomposition
Inverse of a matrix
Also, L−1 and U−1 are calculated to get
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 18
LU Decomposition
Remarks
A positive definite matrix M is invertible.
All the eigenvalues with corresponding real eigenvectors of a positive definite
matrix are positive.
A symmetric matrix is positive definite if: (i) all the diagonal entries are
positive, and (ii) each diagonal entry is greater than the sum of the absolute
values of all other entries in the corresponding row/column.
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 19
Linear system
Cholesky Method
This method is also known as square-root method.
If the coefficient matrix A is symmetric and positive definite, then, it can be
decomposed as
A=LLT (11)
where L = (lij ), lij = 0, i < j
Also, A can be decomposed as A=UUT (12)
For (11), the system of equations becomes
LLT x = b (13)
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 20
Linear system
Cholesky Method
(13) can be written as
LT x = z (14)
Lz = b (15)
The values zi , i = 1, · · · , n are obtained from (15) by forward substitution.
xi , i = 1, · · · , n are determined from (14) by back substitution.
Alternatively, we can also find L−1 and obtain
z=L−1 b (16)
and, x=(LT )−1 z = (L−1 )T z
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 21
Linear system
Cholesky Method
The inverse of A can be obtained from (11)
i−1 1/2
X
lii = aii − lij2 , i = 1, 2, · · · , n
j=1
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 22
Linear system
Cholesky Method
j−1
1 X
lij = aij − ljk lik , i = j + 1, j + 2, · · · , n; j = 1, · · · , n
lii
k =1
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 23
Linear system
Cholesky Method
n
X
uij = aij − uik ujk /ujj ,
k =j+1
i = n − 2, n − 3, · · · , 1; j = i + 1, i + 2, · · · , n − 1
Xn 1/2
2
uii = aii − uik , i = n − 1, n − 2, · · · , 1
k =i+1
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 24
Cholesky Method
Example
Consider the system of equations
4 −1 0 0 x1 1
−1 4 −1 0 x2 0
x3 = 0
0 −1 4 −1
0 0 −1 4 x4 0
We will solve the above system using Cholesky method and determine A−1 .
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 25
Cholesky Method
Example
Suppose
l11 0 0 0
l21 l22 0 0
L= l31 l32 l33 0
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 26
Cholesky Method
Example
2
l11 l11 l21 l11 l31 l11 l41
l21 l11 2 + l2
l21 l21 l31 + l22 l32 l21 l41 + l22 l42
A= 22
l31 l11 l31 l21 + l32 l22 2 2
l31 + l32 + l332 l31 l41 + l32 l42 + l33 l43
2 + l2 + l2 + l2
l41 l11 l41 l21 + l42 l22 l41 l31 + l42 l32 + l43 l33 l41 42 43 44
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 27
Cholesky Method
Example
2 + l 2 = 4, or l
p
Second row: l21 22 22 = 15/4
p
l21 l31 + l22 l32 = −1, or l32 = − 4/15
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 28
Cholesky Method
Example
The solution of system Lz=b i.e.
2 p0 0 0
z1 1
−1/2 15/4 0 0 z2 0
p p =
0 − 4/15 p56/15 p 0 z3 0
0 0 − 15/56 209/56 z4 0
is given by z1 = 21 , z2 = √1 , z3
60
= √ 1 , z4
840
= √ 1
11704
.
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 29
Cholesky Method
Example
The solution vector is obtained from LT x=z, i.e.
−1/2
2 p p0 0 1/2
x1 √
0
15/4 −
p 4/15 p0 x2
1/ 60
= √
0 0 56/15 −
p 15/56 x3 1/ 840
√
0 0 0 209/56 x4 1/ 11704
1 4 15 56
On back substitution, we get the solution x4 = 209 , x3 = 209 , x2 = 209 , x1 = 209 .
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 30
Cholesky Method
Example
We also find
1/2 p0 0 0
√
1/ 60
L−1 √ p 4/15 p 0 0
=
1/ 840
√ p 2/105 p 15/56 p 0
1/ 11704 2/1463 15/11704 56/209
0.5 0 0 0
0.1291 0.5164 0 0
=
0.0345 0.1380 0.5176
0
0.0092 0.0370 0.1387 0.5176
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 31
Cholesky Method
Example
Finally, we obtain
0.2679 0.0718 0.0191 0.0048
0.0718 0.2871 0.0766 0.0192
A−1 =(L−1 )T L−1 =
0.0191
0.0766 0.2871 0.0718
0.0048 0.0192 0.0718 0.2679
NPTEL ONLINE
IIT ROORKEE CERTIFICATION COURSE 32