Docsity

LU Factorization: Finding L and U for Matrix A - Prof. Luke Olson, Study notes of Computer Science

Partial preview of the text

Download LU Factorization: Finding L and U for Matrix A - Prof. Luke Olson and more Study notes Computer Science in PDF only on Docsity!

Lecture 10

LU, Cholesky

N. Bell

Department of Computer Science University of Illinois at Urbana-Champaign

September 27, 2006

Factorization Methods

LU factorization Cholesky factorization Use of the backslash operator

Why use LU?

Decompose once, solve many righthand sides quickly. O(Mn^3 ) with GE vs. O(n^3 + Mn^2 ) with LU Given A = LU you can compute A−^1 , det(A), rank(A), ker(A) etc.

LU Factorization

Since L and U are triangular, it is easy to apply their inverses. Consider the solution to Ax = b.

A = LU =⇒ (LU)x = b

Regroup, matrix multiplication is associative

L(Ux) = b

Let Ux = y, then Ly = b Since L is triangular it is easy (without Gaussian elimination) to compute

y = L−^1 b

This expression should be interpreted as “Solve Ly = b with a forward substitution.”

LU Factorization

Listing 1: Solve Ax

1 Factor A into L and U 2 Solve Ly = b for y use forward substitution 3 Solve Ux = y for x use backward substitution

LU Factorization

Consider the following matrix

A =

After reducing the first column we have

A 1 =

Notice that we can write A 1 as the product of matrices M 1 A

A 1 =

 = M 1 A

LU Factorization

We can continue applying matrices to reduce the other columns  

 = A

 = M 1 A =

 = M 2 M 1 A =

LU Factorization

In our example we determined matrices M 1 and M 2 such that M 2 M 1 A = U was upper triangular. In the general case we have

(MnMn− 1... M 2 M 1 )A = U

So it follows A = (MnMn− 1... M 2 M 1 )−^1 U Now we need to show that (MnMn− 1... M 2 M 1 )−^1 is lower triangular.

LU Factorization

Therefore we have factored A = LU  

1 2 3 1

Caveat: Notice that the LU factorization can be stored in the same space as A. Some implementations overwrite A in the process of computing LU.

When LU goes wrong

Like GE without pivoting, LU fails for some matrices [ 0 1 1 1

]

However with pivoting, the LU always exists. In practice, you get a factorization

LU = PA

where P is a permutation matrix. This even works when A is singular or rectangular.

Cholesky Factorization

A must be symmetric and positive definite (SPD) Factors A into LLt, like LU where U = Lt For SPD matrices, pivoting is not required Cholesky factorization requires one half as many flops as LU factorization. Since pivoting is not required, Cholesky factorization will be more than twice as fast as LU factorization since data movement is avoided. Refer to the text for a view of the algorithm Use built-in chol function for routine work

SPD matrices and you

A matrix is Positive Definite (PD) if for all choices of the vector x the following holds

xtAx > 0

A matrix is SPD if it is symmetric and positive definite. This definition is not particularly intuitive.

SPD matrices are innerproducts

Imagine 2 D space, except that moving in the x-direction is twice as expensive as moving in the y-direction. New innerproduct

[ x y

]

[

] [

x y

]

Taking the norm of a vector [x, y] using this innerproduct represents our modified notion of length.

SPD matrices for profit

In practice we like SPD matrices because They are non-singular (why?) Cholesky is faster than LU Sparse Cholesky is faster than Sparse LU Conjugate Gradient SPD matrices arise in the discritization of many physical problems and are by no means exotic.