Beruflich Dokumente
Kultur Dokumente
Faculty of Engineering
Civil Engineering Department
Numerical Analysis
ECIV 3306
Chapter 10
LU Decomposition and Matrix Inversion
Introduction
Gauss elimination solves [A] {x} ={B}
It becomes insufficient when solving these
equations for different values of {B}
LU decomposition works on the matrix [A] and the
vector {B} separately.
LU decomposition is very useful when the vector of
variables {x} is estimated for different parameter
vectors {B} since the forward elimination process is
not performed on {B}.
LU Decomposition
If:
L: lower triangular matrix
U: upper triangular matrix
Then,
[A]{X}={B} can be decomposed into two
matrices [L] and [U] such that:
1. [L][U] = [A] ([L][U]){X} = {B}
LU Decomposition
([L][U]){X} = {B}
Consider:
[U]{X} = {D}
So, [L]{D} = {B}
2. [L]{D} = {B} is used to generate an
intermediate vector {D} by forward substitution
3. Then, [U]{X}={D} is used to get {X} by back
substitution
Summary of LU Decomposition
LU Decomposition
As in Gauss elimination, LU decomposition must
employ pivoting to avoid division by zero and to
LU Decomposition
System of linear equations [A]{x}={B}
a11 a12
a
a
21
22
a31 a32
a13 x1 b1
l a21
a23 x2 b2 21
a11
a33 x3 b3
a31
l31
a11
[ L][U ] [ A]
1 0
[L ] l 21 1
l 31 l 32
0
1
l32
a '32
a '22
LU Decomposition
Step 2: Generate an intermediate vector {D} by forward
substitution
1 0
l
21 1
l31 l32
0 d1 b1
0 d 2 b2
1 d 3 b3
[L]{D} = {B}
a11 a12
0 a'
22
0
0
a13 x1 d1
a '23 x2 d 2
a' '33 x3 d 3
[U]{X}={D}
LU Decomposition-Example
3 0.1 0.2
A 0.1 7 0.3
0.3 0.2 10
0.2
3 0.1
0 7.003 0.293
0 0.19 10.02
0.1
0.3
l 21
0.03333; l 31
0.1000
3
3
a32\
0.19
l 32 \
0.02713
a22 7.003
0.2
3 0.1
U 0 7.003 0.293
0
0
10
.
012
0
0
1
[L ] 0.03333
1
0
0.1000 .02713 1
LU Decomposition-Example (contd)
Use previous [L] and {D} matrices to solve the system:
3 0.1 0.2 x1 7.85
0.1
7
0.31 x2 19.3
0
0 d1 7.85 d1 7.85
1
0.0333
d 19.3 d 19.5617
1
0
2
2
0.1000 0.02713 1 d 3 71.4 d 3 70.0843
LU Decomposition-Example (contd)
Step 3: Get {X} by back substitution.
0.2 x1 7.85 x1 3
3 0.1
0 7.0033 0.2933 x 19.5617 x 2.5
2
2
0
0
10.012 x3 70.0843 x3 7.00003
Decomposition Step
% Decomposition Step
for k=1:n-1
[a,o]= pivot(a,o,k,n);
for i = k+1:n
a(i,k) = a(i,k)/a(k,k);
a(i,k+1:n)= a(i,k+1:n)-a(i,k)*a(k,k+1:n);
end
end
Partial Pivoting
%Partial Pivoting
function [a,o] = pivot(a,o,k,n)
[big piv]=max(abs(a(k:n,k)));
piv=piv+(k-1);
if piv ~= k
temp = a(piv,:);
a(piv,:)= a(k,:);
a(k,:)=temp;
temp = o(piv);
o(piv)=o(k);
o(k)=temp;
end
Substitution Steps
%Forward Substitution
d(1)=bn(1);
for i=2:n
d(i)=bn(i)-a(i,1:i-1)*(d(1:i-1))';
end
% Back Substitution
x(n)=d(n)/a(n,n);
for i=n-1:-1:1
x(i)=(d(i)-a(i,i+1:n)*x(i+1:n)')/a(i,i);
end
Ax1 {b}1
Ax2 {b}2
Ax3 {b}3
1
0
0
0
1
0
0
0
1
Ax1
1st column
of [A]-1
Ax2
2nd column
of [A]-1
Ax3
3rd column
of [A]-1
0
0
1
[L ] 0.03333
1
0
0.1000 .02713 1
0.2
3 0.1
U 0 7.003 0.293
0
0
10.012
0.0333
d 0 d 0.03333
1
0
2 2
0.1000 0.02713 1 d 3 0 d 3 0.1009 1st column
of [A]-1
0.2 x1 1
3 0.1
x1 0.33249
0 7.0033 0.2933 x 0.03333 x 0.00518
2
2
0
0
10.012 x3 0.1009 x3 0.01008
0
0 d1 0 d1 0
1
0.0333
1
0 d 2 1 d 2 1
2nd column
of [A]-1
0.2 x1 0 x1 0.004944
3 0.1
0 7.0033 0.2933 x 1 x 0.142903
2
2
0
0
10.012 x3 0.02713 x3 0.00271
2 2
0.1000 0.02713 1 d 3 1 d 3 1
3rd column
of [A]-1
0.2 x1 0 x1 0.006798
3 0.1
0 7.0033 0.2933 x 0 x 0.004183
2 2
0
0
10.012 x3 1 x3 0.09988
F e a 2 b2 c2
Length or Euclidean norm of [F]
2
x
i
i 1
Frobenius norm
i 1 j 1
ai2, j
(10.24)
P-Norm
1/ p
X p xi
i 1
1-Norm
We can also see that Euclidean norm and the 2
norm, ||X||, For
areVector
identical for vectors.
n
X 1 xi
i 1
In contrast to vectors,
the 2 norm and Euclidean
For Matrix
(Column
Sum Norm)
norm for amatrix
are not
the same.
1/ p
X p xi
Vector
and
Matrix
i 1
1-Norm
For Vector
n
Norms (contd)
X 1 xi
i 1
A 1 max ai , j
1 j n
i 1
max ai , j
1i n
j 1
1i n
Cond A A A
Cond A
A
A
Iterative Refinement
Round-off errors can be reduced by the following procedure:
~ T ~ ~ ~
X [ x1 x2 x3 ]
~
~
~
~
a11x1 a12 x2 a13 x3 b1
~ ....(Eq.1)
~
~
~
a21x1 a22 x2 a23 x3 b2
~
~
~
~
a31x1 a32 x2 a33 x3 b3
x3 ~
x3 x3
Then:
a11( ~
x1 x1 ) a12 ( ~
x2 x2 ) a13 ( ~
x3 x3 ) b1
a21( ~
x1 x1 ) a22 ( ~
x2 x2 ) a23 ( ~
x3 x3 ) b2 .(Eq.2)
a (~
x x ) a ( ~
x x ) a ( ~
x x ) b
31
32
33
~
a11x1 a12x2 a13x3 b1 b1 E1
~
a21x1 a22x2 a23x3 b2 b2 E2
~
a31x1 a32x2 a33x3 b3 b3 E3
The factors then can be applied to improve the solution as
~
x
x3 ~
x3 x3
X T [1.00
1.00 1.00]
~ T
X [0.991 0.997 1.00]
~
~
[ A]{X } {C}
5.24511
~
{C} 5.22246
2.59032
X T [0.00822
0.00300 0.00000757]
x1 ~
x1 x1 0.999
x ~
x x 1.00
2
x3 ~
x3 x3 1.00