Calculo Numérico I
Descomposición LU e
Inversión de Matrices
Dr. Luis Sanchez
LU Decomposition and Matrix Inversion
• Gauss elimination, in which the forward elimination
comprises the bulk of the computational effort, can be
implemented as an LU decomposition.
• Provides an efficient way to compute matrix inverse by
separating the time consuming elimination of the Matrix
[A] from manipulations of the right-hand side {B}.
LU Decomposition: Introduction
LU decomposition was originally derived as a decomposition of quadratic
and bilinear forms. Lagrange, in the very first paper in his collected works(
1759) derives the algorithm we call Gaussian elimination. Later Turing
introduced the LU decomposition of a matrix in 1948 that is used to solve the
system of linear equation.
Let A be a m × m with nonsingular square matrix. Then there exists two
matrices L and U such that, where L is a lower triangular matrix and U is an
upper triangular matrix.
u11 u12 u1m l11 0 0
0 u u 2 m l l 22 0
U 22
and L 21
0 0 u mm l m1 lm2 l mm
J-L Lagrange
Where, A LU A. M. Turing
(1736 –1813) (1912-1954)
Introduction
• Gauss elimination solves [A] {x} ={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
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 minimize round
off errors. The pivoting is done immediately after
computing each column.
LU Decomposition
System of linear equations [A]{x}={B}
a12 a31
a11 a12 a13 x1 b1 l 21 ; l 31
a a11 a11
21 a22 a23 x2 b2
a32\
a31 a32 a33 x3 b3 l 32 \
a22
Step 1: Decomposition [ L][U ] [ A]
a11 a12 a13 1 0 0
[U ] 0 a22/ a23/
[L ] l 21 1 0
0 0 a33
//
l 31 l 32 1
LU Decomposition
Step 2: Generate an intermediate vector {D} by forward
substitution
1 0 0 d1 b1
l
21 1 0 d 2 b2
l31 l32 1 d 3 b3
Step 3: Get {X} by back substitution.
a11 a12 a13 x1 d1
0 a'
22 a '23 x2 d 2
0 0 a ' '33 x3 d 3
LU Decomposition-Example
3 0.1 0.2 3 0.1 0.2
A 0.1 7 0.3
0.3 0.2 10
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
3 0.1 0.2 1 0 0
U 0 7.003 0.293 [L ] 0.03333 1 0
0 0.1000 .02713 1
0 10 .012
LU Decomposition-Example (cont’d)
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.3 0.2 10 x3 71.4
Step 2: Find the intermediate vector {D} by forward substitution
1 0 0 d1 7.85 d1 7.85
0.0333
1 0 d 2 19.3 d 2 19.5617
0.1000 0.02713 1 d 3 71.4 d 3 70.0843
LU Decomposition-Example (cont’d)
Step 3: Get {X} by back substitution.
3 0.1 0.2 x1 7.85 x1 3
0 7.0033 0.2933 x 19.5617 x 2.5
2 2
0 0 10.012 x3 70.0843 x3 7.00003
Matrix Inverse Using the LU
Decomposition
• LU decomposition can be used to obtain the inverse of
the original coefficient matrix [A].
• Each column j of the inverse is determined by using a
unit vector (with 1 in the jth raw ).
Matrix Inverse: LU Decomposition
[A] [A]-1 = [A]-1[A] = I
Ax1 {b}1 Ax2 {b}2 Ax3 {b}3
1 0 0
Ax1 0 Ax2 1 Ax3 0
0 0 1
1st column 2nd column 3rd column
of [A]-1 of [A]-1 of [A]-1
A 1
{x}1 {x}2 {x}3
Matrix inverse using LU decomposition Example
3 0.1 0.2 1 0 0 3 0.1 0.2
A 0.1 7 0.3 [L ] 0.03333 1 0 U 0 7.003 0.293
0.3 0.2 10 0.1000 .02713 1 0 10.012
0
1A. [L]{d}1 = {b}1
1 0 0 d1 1 d1 1
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
1B. Then, [U]{X}1={d}1 [A]-1
3 0.1 0.2 x1 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
Matrix inverse using LU decomposition Example
(cont’d)
2A. [L]{d}2 = {b}2
1 0 0 d1 0 d1 0
0.0333
1 0 d 2 1 d 2 1
0.1000 0.02713 1 d 3 0 d 3 0.02713
2nd column of
2B. Then, [U]{X}2={d}2 [A]-1
3 0.1 0.2 x1 0 x1 0.004944
0 7.0033 0.2933 x 1 x 0.142903
2 2
0 0 10.012 x3 0.02713 x3 0.00271
Matrix inverse using LU decomposition Example
(cont’d)
3A. [L]{d}3 = {b}3
1 0 0 d1 0 d1 0
0.0333 d 0 d 0
1 0 2 2
0.1000 0.02713 1 d 3 1 d 3 1
3B. Then, [U]{X}3={d}3 3rd column of
[A]-1
3 0.1 0.2 x1 0 x1 0.006798
0 7.0033 0.2933 x 0 x 0.004183
2 2
0 0 10.012 x3 1 x3 0.09988
Matrix inverse using LU decomposition Example
(cont’d)
0.33249 0.004944 0.006798
[ A]1 0.00518 0.142903 0.004183
0.01008 0.00271 0.09988