lu factorization - unc charlotte faq - unc charlottelu decomposition a matrix a can be decomposed...

29
LU Factorization To further improve the efficiency of solving linear systems Factorizations of matrix A : LU and QR LU Factorization Methods: Using basic Gaussian Elimination (GE) Factorization of Tridiagonal Matrix Using Gaussian Elimination with pivoting Direct LU Factorization Factorizing Symmetrix Matrices (Cholesky Decomposition) Applications Analysis ITCS 4133/5133: Intro. to Numerical Methods 1 LU/QR Factorization

Upload: others

Post on 16-Oct-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU Factorization

� To further improve the efficiency of solving linear systems

� Factorizations of matrix A : LU and QR

� LU Factorization Methods:

◦ Using basic Gaussian Elimination (GE)◦ Factorization of Tridiagonal Matrix◦ Using Gaussian Elimination with pivoting◦ Direct LU Factorization◦ Factorizing Symmetrix Matrices (Cholesky Decomposition)

� Applications

� Analysis

ITCS 4133/5133: Intro. to Numerical Methods 1 LU/QR Factorization

Page 2: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU Decomposition

� A matrix A can be decomposed into a lower triangular matrix L andupper triangular matrix U so that

A = LU

� LU decomposition is performed once; can be used to solve multipleright hand sides.

� Similar to Gaussian elimination, care must be taken to avoid roundofferrors (partial or full pivoting)

� Special Cases: Banded matrices, Symmetric matrices.

ITCS 4133/5133: Intro. to Numerical Methods 2 LU/QR Factorization

Page 3: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU Decomposition: Motivation

ITCS 4133/5133: Intro. to Numerical Methods 3 LU/QR Factorization

Page 4: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU DecompositionForward pass of Gaussian elimination results in the upper triangular ma-trix

U =

1 u12 u13 · · · u1n

0 1 u23 · · · u2n

0 0 1 · · · u3n... ... ... ... ...0 0 0 · · · 1

We can determine a matrix L such that

LU = A , and

L =

l11 0 0 · · · 0l21 l22 0 · · · 0l31 l32 l33 · · · 0... ... ... ... ...

ln1 ln2 ln3 · · · 1

ITCS 4133/5133: Intro. to Numerical Methods 4 LU/QR Factorization

Page 5: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU Decomposition via Basic GaussianElimination

ITCS 4133/5133: Intro. to Numerical Methods 5 LU/QR Factorization

Page 6: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU Decomposition via Basic GaussianElimination: Algorithm

ITCS 4133/5133: Intro. to Numerical Methods 6 LU/QR Factorization

Page 7: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Banded Matrices

� Matrices that have non-zero elements close to the main diagonal

� Example: matrix with a bandwidth of 3 (or half band of 1)a11 a12 0 0 0a21 a22 a23 0 00 a32 a33 a34 00 0 a43 a44 a450 0 0 a54 a55

� Efficiency: Reduced pivoting needed, as elements below bands are

zero.

� Iterative techniques are generally more efficient for sparse matrices,such as banded systems.

ITCS 4133/5133: Intro. to Numerical Methods 7 LU/QR Factorization

Page 8: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU Decomposition of Tridiagonal Matrix

ITCS 4133/5133: Intro. to Numerical Methods 8 LU/QR Factorization

Page 9: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU Decomposition of Tridiagonal Matrix:Algorithm

ITCS 4133/5133: Intro. to Numerical Methods 9 LU/QR Factorization

Page 10: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU Decomposition via GE with Pivoting

ITCS 4133/5133: Intro. to Numerical Methods 10 LU/QR Factorization

Page 11: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU Decomposition via GE with Pivoting:Algorithm

ITCS 4133/5133: Intro. to Numerical Methods 11 LU/QR Factorization

Page 12: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Direct LU Decomposition

l11 0 0 · · · 0l21 l22 0 · · · 0l31 l32 l33 · · · 0... ... ... ... ...

ln1 ln2 ln3 · · · 1

1 u12 u13 · · · u1n

0 1 u23 · · · u2n

0 0 1 · · · u3n... ... ... ... ...0 0 0 · · · 1

=

a11 a12 a13 · · · a1n

a21 a22 a23 · · · a2n

a31 a32 a33 · · · a2n... ... ... ... ...

an1 an2 an3 · · · ann

The above equation shows the coefficient matrix A can be decomposedinto L and U ; L and U can be determined by the computing the productand equating like terms.

ITCS 4133/5133: Intro. to Numerical Methods 12 LU/QR Factorization

Page 13: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Determining L and U

li1 = ai1, i = 1, 2, . . . , n

u1j =a1j

l11, j = 2, 3, . . . , n

lij = aij −j−1∑k=1

likukj,

for j = 2, 3, . . . , n− 1 and i = j, j + 1, . . . , n

uji =aji −

∑j−1k=1 ljkuki

ljj,

for j = 2, 3, . . . , n− 1 and i = j + 1, j + 2, . . . , n

lnn = ann −n−1∑k=1

lnkukn

ITCS 4133/5133: Intro. to Numerical Methods 13 LU/QR Factorization

Page 14: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Direct LU Decomposition: Example

ITCS 4133/5133: Intro. to Numerical Methods 14 LU/QR Factorization

Page 15: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Direct LU Decomposition: Algorithm

ITCS 4133/5133: Intro. to Numerical Methods 15 LU/QR Factorization

Page 16: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Symmetric Matrices

� Symmetric square matrices - common in engineering, for examplestiffness matrix (stiffness properties of structures).

� For a symmetric matrix A

A = AT

where AT is the transpose of A. Hence

� For a symmetric matrix A

A = LLT

ITCS 4133/5133: Intro. to Numerical Methods 16 LU/QR Factorization

Page 17: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Symmetric Matrices: LU Decomposition

� We can use Cholesky Decomposition to compute the LU decompo-sition of A

l11 =√

a11

lii =

√√√√aii −i−1∑k=1

l2ik, for i = 2, 3, . . . , n

lij =aij −

∑j−1k=1 likljk

ljj, for j = 2, 3, . . . , i− 1, and j < 1

ITCS 4133/5133: Intro. to Numerical Methods 17 LU/QR Factorization

Page 18: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU (Cholesky) Decomposition of SymmetricMatrices

ITCS 4133/5133: Intro. to Numerical Methods 18 LU/QR Factorization

Page 19: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

LU (Cholesky) Decomposition: Algorithm

ITCS 4133/5133: Intro. to Numerical Methods 19 LU/QR Factorization

Page 20: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Applications of LU Decomposition:SolvingLinear systems

[A] ~X = [L][U ][ ~X ] = C

= [L]~e = C

where ~e = [U ] ~X

� Solve for ~e using L (forward substitution)

� Solve for ~X using U (back substitution)

ITCS 4133/5133: Intro. to Numerical Methods 20 LU/QR Factorization

Page 21: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Solving Linear Systems

Forward Substitution

Solve for ~e,

e1 =C1

l11

ei =Ci −

∑nj=1 lijej

lii, for i = 2, 3, . . . n

Back SubstitutionSolve for ~X

Xn = en

Xi = ei −n∑

j=i+1

uijXj, for i = n− 1, n− 2, . . . 1

ITCS 4133/5133: Intro. to Numerical Methods 21 LU/QR Factorization

Page 22: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Solving Linear Systems: Example

ITCS 4133/5133: Intro. to Numerical Methods 22 LU/QR Factorization

Page 23: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Solving Linear Systems: Algorithm

ITCS 4133/5133: Intro. to Numerical Methods 23 LU/QR Factorization

Page 24: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Application 2: Tridiagonal Systems

ITCS 4133/5133: Intro. to Numerical Methods 24 LU/QR Factorization

Page 25: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Application 3: Matrix Inverse

ITCS 4133/5133: Intro. to Numerical Methods 25 LU/QR Factorization

Page 26: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Analysis: LU Decomposition� Why does LU decomposition work?

� Consider the first elimination step: 1 0 0m21 1 0m31 0 1

a11 a12 a13a21 a22 a23a31 a32 a33

=

a11 a12 a13

0 a′

22 a′

230 a

32 a′

33

� Define

M1 =

1 0 0m21 1 0m31 0 1

, M2 =

1 0 00 1 00 m32 1

� Hence

M1−1 =

1 0 0−m21 1 0−m31 0 1

, M2−1 =

1 0 00 1 00 −m32 1

,

ITCS 4133/5133: Intro. to Numerical Methods 26 LU/QR Factorization

Page 27: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Analysis: LU Decomposition

� Gradual tranformation of I towards LU:

I.A = A

I.M1−1.M1.A = A

I.M1−1.M2

−1.M2.M1.A = A

� M2.M1.A is U and I.M1−1.M2

−1 is L, given by 1 0 0−m21 1 0−m31 −m32 1

ITCS 4133/5133: Intro. to Numerical Methods 27 LU/QR Factorization

Page 28: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

Analysis:LU Decomposition with Pivoting� Decomposition results in the factorization of PA, where P is the

permutation matrix.[1 0 00 1 00 0 1

] [a11 a12 a13

a21 a22 a23

a31 a32 a33

]=

[a11 a12 a13

a21 a22 a23

a31 a32 a33

]� Assume no pivoting in column 1, pivoting in column 2:

I.A = A

I.M1−1.M1.A = A

I.M1−1.P.P.M1.A = A

I.M1−1.P.M2

−1.M2.P.M1.A = A

� M2.P.M1.A is upper triangular, but I.M1−1.P.M2

−1 is not lower tri-angular.

� Premultiply both sides by P :

PM1−1.P.M2

−1.M2.P.M1.A = P.AITCS 4133/5133: Intro. to Numerical Methods 28 LU/QR Factorization

Page 29: LU Factorization - UNC Charlotte FAQ - UNC CharlotteLU Decomposition A matrix A can be decomposed into a lower triangular matrix L and upper triangular matrix U so that A = LU LU decomposition

ITCS 4133/5133: Intro. to Numerical Methods 29 LU/QR Factorization