7 Gaussian Elimination and LU Factorization



Similar documents
Abstract: We describe the beautiful LU factorization of a square matrix (or how to write Gaussian elimination in terms of matrix multiplication).

Direct Methods for Solving Linear Systems. Matrix Factorization

7. LU factorization. factor-solve method. LU factorization. solving Ax = b with A nonsingular. the inverse of a nonsingular matrix

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

Solution of Linear Systems

SOLVING LINEAR SYSTEMS

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

Factorization Theorems

Solving Linear Systems, Continued and The Inverse of a Matrix

Lecture 3: Finding integer solutions to systems of linear equations

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

Elementary Matrices and The LU Factorization

6. Cholesky factorization

Solving Systems of Linear Equations

1 Solving LPs: The Simplex Algorithm of George Dantzig

Notes on Determinant

Solving Linear Systems of Equations. Gerald Recktenwald Portland State University Mechanical Engineering Department

Systems of Linear Equations

13 MATH FACTS a = The elements of a vector have a graphical interpretation, which is particularly easy to see in two or three dimensions.

Vector and Matrix Norms

1.2 Solving a System of Linear Equations

The Characteristic Polynomial

Linear Programming. March 14, 2014

Au = = = 3u. Aw = = = 2w. so the action of A on u and w is very easy to picture: it simply amounts to a stretching by 3 and 2, respectively.

Unit 18 Determinants

Row Echelon Form and Reduced Row Echelon Form

CS3220 Lecture Notes: QR factorization and orthogonal transformations

Similar matrices and Jordan form

10.2 ITERATIVE METHODS FOR SOLVING LINEAR SYSTEMS. The Jacobi Method

Lecture 1: Systems of Linear Equations

Continued Fractions and the Euclidean Algorithm

Practical Guide to the Simplex Method of Linear Programming

Solution to Homework 2

Methods for Finding Bases

Lecture 1: Schur s Unitary Triangularization Theorem

by the matrix A results in a vector which is a reflection of the given

Operation Count; Numerical Linear Algebra

MATRICES WITH DISPLACEMENT STRUCTURE A SURVEY

Solving Systems of Linear Equations

[1] Diagonal factorization

Matrices 2. Solving Square Systems of Linear Equations; Inverse Matrices

Numerical Methods I Eigenvalue Problems

a 11 x 1 + a 12 x a 1n x n = b 1 a 21 x 1 + a 22 x a 2n x n = b 2.

DETERMINANTS TERRY A. LORING

1 VECTOR SPACES AND SUBSPACES

Introduction to Matrix Algebra

LINEAR ALGEBRA. September 23, 2010

Linear Programming in Matrix Form

Solving Systems of Linear Equations Using Matrices

SYSTEMS OF EQUATIONS AND MATRICES WITH THE TI-89. by Joseph Collison

University of Lille I PC first year list of exercises n 7. Review

Using row reduction to calculate the inverse and the determinant of a square matrix

Iterative Methods for Solving Linear Systems

Linear Algebra: Determinants, Inverses, Rank

DATA ANALYSIS II. Matrix Algorithms

October 3rd, Linear Algebra & Properties of the Covariance Matrix

Solutions to Math 51 First Exam January 29, 2015

SECOND DERIVATIVE TEST FOR CONSTRAINED EXTREMA

Linear Algebra Notes for Marsden and Tromba Vector Calculus

2x + y = 3. Since the second equation is precisely the same as the first equation, it is enough to find x and y satisfying the system

Suk-Geun Hwang and Jin-Woo Park

8 Square matrices continued: Determinants

Numerical Methods I Solving Linear Systems: Sparse Matrices, Iterative Methods and Non-Square Systems

Matrix Representations of Linear Transformations and Changes of Coordinates

Continuity of the Perron Root

LS.6 Solution Matrices

NOTES ON LINEAR TRANSFORMATIONS

Chapter 19. General Matrices. An n m matrix is an array. a 11 a 12 a 1m a 21 a 22 a 2m A = a n1 a n2 a nm. The matrix A has n row vectors

1 Review of Least Squares Solutions to Overdetermined Systems

MAT 200, Midterm Exam Solution. a. (5 points) Compute the determinant of the matrix A =

160 CHAPTER 4. VECTOR SPACES

3. Mathematical Induction

A note on companion matrices

Similarity and Diagonalization. Similar Matrices

3.2. Solving quadratic equations. Introduction. Prerequisites. Learning Outcomes. Learning Style

Math Lecture 33 : Positive Definite Matrices

Linear Programming. April 12, 2005

1 Introduction. Linear Programming. Questions. A general optimization problem is of the form: choose x to. max f(x) subject to x S. where.

Inner Product Spaces

Notes on Symmetric Matrices

Orthogonal Bases and the QR Algorithm

The Singular Value Decomposition in Symmetric (Löwdin) Orthogonalization and Data Compression

General Framework for an Iterative Solution of Ax b. Jacobi s Method

OPRE 6201 : 2. Simplex Method

Linear Equations ! $ & " % & " 11,750 12,750 13,750% MATHEMATICS LEARNING SERVICE Centre for Learning and Professional Development

UNCOUPLING THE PERRON EIGENVECTOR PROBLEM

CHAPTER 5 Round-off errors

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

Math 115A HW4 Solutions University of California, Los Angeles. 5 2i 6 + 4i. (5 2i)7i (6 + 4i)( 3 + i) = 35i + 14 ( 22 6i) = i.

The Determinant: a Means to Calculate Volume

Data Mining: Algorithms and Applications Matrix Math Review

Eigenvalues and Eigenvectors

Linear Programming for Optimization. Mark A. Schulze, Ph.D. Perceptive Scientific Instruments, Inc.

MATH 304 Linear Algebra Lecture 18: Rank and nullity of a matrix.

The Graphical Method: An Example

Numerical Analysis Lecture Notes

Lecture Notes 2: Matrices as Systems of Linear Equations

1 Determinants and the Solvability of Linear Systems

Standard Form of a Linear Programming Problem

Notes on Orthogonal and Symmetric Matrices MENU, Winter 2013

Transcription:

7 Gaussian Elimination and LU Factorization In this final section on matrix factorization methods for solving Ax = b we want to take a closer look at Gaussian elimination (probably the best known method for solving systems of linear equations) The basic idea is to use left-multiplication of A C m m by (elementary) lower triangular matrices, L, L,, L m to convert A to upper triangular form, ie, L m L m L L } {{ } A = U = e L Note that the product of lower triangular matrices is a lower triangular matrix, and the inverse of a lower triangular matrix is also lower triangular Therefore, LA = U A = LU, where L = L This approach can be viewed as triangular triangularization 7 Why Would We Want to Do This? Consider the system Ax = b with LU factorization A = LU Then we have L }{{} Ux = b =y Therefore we can perform (a now familiar) -step solution procedure: Solve the lower triangular system Ly = b for y by forward substitution Solve the upper triangular system Ux = y for x by back substitution Moreover, consider the problem AX = B (ie, many different right-hand sides that are associated with the same system matrix) In this case we need to compute the factorization A = LU only once, and then and we proceed as before: AX = B LUX = B, Solve LY = B by many forward substitutions (in parallel) Solve UX = Y by many back substitutions (in parallel) In order to appreciate the usefulness of this approach note that the operations count for the matrix factorization is O( 3 m3 ), while that for forward and back substitution is O(m ) Example Take the matrix A = 3 5 59

and compute its LU factorization by applying elementary lower triangular transformation matrices We choose L such that left-multiplication corresponds to subtracting multiples of row from the rows below such that the entries in the first column of A are zeroed out (cf the first homework assignment) Thus L A = 0 0 0 4 0 3 5 = 0 3 0 4 Next, we repeat this operation analogously for L (in order to zero what is left in column of the matrix on the right-hand side above): 0 0 L (L A) = 0 0 0 3 = 0 3 = U 0 0 4 0 0 Now L = (L L ) = L so that L = L with 0 0 0 4 0 L = and L = 0 0 0 4 0 0 0 0 0 Remark Note that L always is a unit lower triangular matrix, ie, it has ones on the diagonal Moreover, L is always obtained as above, ie, the multipliers are accumulated into the lower triangular part with a change of sign The claims made above can be verified as follows First, we note that the multipliers in L k are of the form l jk = a jk, j = k +,, m, a kk so that Now, let L k = l k+,k l m,k l k = 0 0 l k+,k 60 l m,k,

Then L k = I l k e k, and therefore (I l k e k } {{ } ) (I + l k ek ) = I l } {{ } k e k l ke k = I, =L k L k since the inner product e k l k = 0 because the only nonzero entry in e k (the in the k-th position) does not hit any nonzero entries in l k which start in the k + -st position So, for any k we have L k = l k+,k l m,k as claimed In addition, L k L k+ = (I + l k e k ) ( I + l k+ e ) k+ = I + l k e k + l k+e k+ + l k e k l k+ } {{ } =0 and in general we have = L = L L m = l k+,k We can summarize the factorization in Algorithm (LU Factorization) Initialize U = A, L = I for k = : m for j = k + : m e k+ l k+,k+ l m,k l m,k+ l, l 3, l m, l m, l m,m, 6

end L(j, k) = U(j, k)/u(k, k) U(j, k : m) = U(j, k : m) L(j, k)u(k, k : m) end Remark In practice one can actually store both L and U in the original matrix A since it is known that the diagonal of L consists of all ones The LU factorization is the cheapest factorization algorithm Its operations count can be verified to be O( 3 m3 ) However, LU factorization cannot be guaranteed to be stable The following examples illustrate this fact Example A fundamental problem is given if we encounter a zero pivot as in A = 5 = L A = 0 0 3 0 4 Now the (,) position contains a zero and the algorithm will break down since it will attempt to divide by zero Example A more subtle example is the following backward instability Take A = + ε 5 with small ε If ε = then we have the initial example in this chapter, and for ε = 0 we get the previous example LU factorization will result in and The multipliers were L A = L L A = L = 0 ε 3 0 4 0 ε 3 0 0 4 6 ε 0 0 0 4 ε Now we assume that a right-hand side b is given as b = 0 0 and we attempt to solve Ax = b via 6 = U

Solve Ly = b Solve Ux = y If ε is on the order of machine accuracy, then the 4 in the entry 4 6 ε insignificant Therefore, we have Ũ = 0 ε 3 and L = L, 0 0 6 ε in U is which leads to LŨ = + ε 5 4 6 4 A In fact, the product is significantly different from A Thus, using L and Ũ we are not able to solve a nearby problem, and thus the LU factorization method is not backward stable If we use the factorization based on L and Ũ with the above right-hand side b, then we obtain 3 ε x = 3 ε 3 3 Whereas if we were to use the exact factorization A = LU, then we get the exact answer 7 3 x = 3 3 4ε 7 ε 3 ε 3 ε ε 3 Remark Even though L and Ũ are close to L and U, the product LŨ is not close to LU = A and the computed solution x is worthless 7 Pivoting Example The breakdown of the algorithm in our earlier example with L A = 0 0 3 0 3 can be prevented by simply swapping rows, ie, instead of trying to apply L to L A we first create 0 0 P L A = 0 0 L A = 0 3 0 0 0 0 3 and are done 63

More generally, stability problems can be avoided by swapping rows before applying L k, ie, we perform L m P m L P L P A = U The strategy we use for swapping rows in step k is to find the largest element in column k below (and including) the diagonal the so-called pivot element and swap its row with row k This process is referred to as partial (row) pivoting Partial column pivoting and complete (row and column) pivoting are also possible, but not very popular Example Consider again the matrix A = + ε 5 The largest element in the first column is the 4 in the (3, ) position This is our first pivot, and we swap rows and 3 Therefore 0 0 P A = 0 0 + ε 5 = + ε 5, 0 0 and then L P A = 0 0 0 4 0 + ε 5 = 0 ε 0 Now we need to pick the second pivot element For sufficiently small ε (in fact, unless < ε < 3 ), we pick ε as the largest element in the second column below the first row Therefore, the second permutation matrix is just the identity, and we have 0 0 P L P A = 0 0 0 ε = 0 ε 0 0 0 0 To complete the elimination phase, we need to perform the elimination in the second column: 0 0 L P L P A = 0 0 0 ε = 0 ε = U 0 (ε ) 0 3 ε 0 0 (ε ) The lower triangular matrix L is given by L = L L = 0 0 0 4 and assuming that ε we get 0 0 L = 0 and Ũ = 4 64 (ε ), 0 0 0 3

If we now check the computed factorization LŨ, then we see LŨ = 5 = P Ã, which is just a permuted version of the original matrix A with permutation matrix 0 0 P = P P = 0 0 0 0 Thus, this approach was backward stable Finally, since we have the factorization P A = LU, we can solve the linear system Ax = b as P Ax = P b LUx = P b, and apply the usual two-step procedure Solve the lower triangular system Ly = P b for y Solve the upper triangular system Ux = y for x This yields x = 7+4ε 3+ε ε 3 ε ε 3 If we use the rounded factors L and Ũ instead, then the computed solution is 7 3 x = 3, 3 which is the exact answer to the problem (see also the Maple worksheet 473 LUmws) 7 3 3 3 In general, LU factorization with pivoting results in P A = LU, where P = P m P m P P, and L = (L m L m L L ) with L k = P m P k+ L k P k+ P m, ie, L k is the same as L k except that the entries below the diagonal are appropriately permuted In particular, L k is still lower triangular Remark Since the permutation matrices used here involve only a single row swap each we have P k = P k (while in general, of course, P = P T ) In the example above L = L, and L = P L P = L since P = I 65

Remark Due to the pivoting strategy the multipliers will always satisfy l ij A possible interpretation of the pivoting strategy is that the matrix P is determined so that it would yield a permuted matrix A whose standard LU factorization is backward stable Of course, we do not know how to do this in advance, and so the P is determined as the algorithm progresses An algorithm for the factorization of an m m matrix A is given by Algorithm (LU Factorization with Partial Pivoting) Initialize U = A, L = I, P = I for k = : m end find i k to maximize U(i, k) U(k, k : m) U(i, k : m) L(k, : k ) L(i, : k ) P (k, :) P (i, :) for j = k + : m end L(j, k) = U(j, k)/u(k, k) U(j, k : m) = U(j, k : m) L(j, k)u(k, k : m) The operations count for this algorithm is also O( 3 m ) However, while the swaps for partial pivoting require O(m ) operations, they would require O(m 3 ) operations in the case of complete pivoting Remark The algorithm above is not really practical since one would usually not physically swap rows Instead one would use pointers to the swapped rows and store the permutation operations instead 73 Stability We saw earlier that Gaussian elimination without pivoting is can be unstable According to our previous example the algorithm with pivoting seems to be stable What can be proven theoretically? Since the entries of L are at most in absolute value, the LU factorization becomes unstable if the entries of U are unbounded relative to those of A (we need L U = O( P A ) Therefore we define a growth factor One can show ρ = max i,j U(i, j) max i,j A(i, j) Theorem 7 Let A C m m Then LU factorization with partial pivoting guarantees that ρ m 66

This bound is unacceptably high, and indicates that the algorithm (with pivoting) can be unstable The following (contrived) example illustrates this Example Take A = 0 0 0 0 0 0 Then LU factorization produces the following sequence of matrices: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 4 0 0 0 4 0 0 0 0 0 0 0 0 0 4 0 0 0 8 0 0 0 8 and we see that the largest element in U is 6 = m 0 0 0 0 0 0 0 0 0 4 0 0 0 8 0 0 0 0 6 = U, Remark BUT in practice it turns out that matrices which such large growth factors almost never arise For most practical cases a realistic bound on ρ seems to be m This is still an active area of research and some more details can be found in the [Trefethen/Bau] book In summary we can say that for most practical purposes LU factorization with partial pivoting is considered to be a stable algorithm 74 Cholesky Factorization In the case when the matrix A is Hermitian (or symmetric) positive definite we can devise a faster (and more stable) algorithm Recall that A C m m is Hermitian if A = A This implies x Ay = y Ax for any x, y C m (see homework for details) If we let y = x then we see that x Ax is real Now, if x Ax > 0 for any x 0 then A is called Hermitian positive definite Remark Symmetric positive definite matrices are defined analogously with replaced by T 74 Some Properties of Positive Definite Matrices Assume A C m m is positive definite If X C m n has full rank, then X AX C n n is positive definite 67

Any principal submatrix (ie, the intersection of a set of rows and the corresponding columns) of A is positive definite 3 All diagonal entries of A are positive and real 4 The maximum element of A is on the diagonal 5 All eigenvalues of A are positive 74 How Does Cholesky Factorization Work? Consider the Hermitian positive definite A C m m in block form [ ] w A = w K and apply the first step of the LU factorization algorithm Then [ ] [ ] 0 T w A = w I 0 K ww The main idea of the Cholesky factorization algorithms is to take advantage of the fact that A is Hermitian and perform operations symmetrically, ie, also zero the first row Thus [ ] [ ] [ ] 0 T 0 T w A = w I 0 K ww 0 I Note that the three matrices are lower triangular, block-diagonal, and upper triangular (in fact the adjoint of the lower triangular factor) Now we continue iteratively However, in general A will not have a in the upper left-hand corner We will have to be able to deal with an arbitrary (albeit positive) entry in the (,) position Therefore we reconsider the first step with slightly more general notation, ie, [ a w A = ] w K so that A = [ a 0 T a w I ] [ 0 T 0 K a ww ] [ a a w 0 I ] = R A R Now we can iterate on the inner matrix A Note that the (,) entry of K ww /a has to be positive since A was positive definite and R is nonsingular This guarantees that A = R AR is positive definite and therefore has positive diagonal entries The iteration yields A = RA R so that and eventually A = R R A R R, A = RR Rm R } {{ } m R R, } {{ } =R =R 68

the Cholesky factorization of A Note that R is upper triangular and its diagonal is positive (because of the square roots) Thus we have proved Theorem 7 Every Hermitian positive definite matrix A has a unique Cholesky factorization A = R R with R an upper triangular matrix with positive diagonal entries Example Consider A = 4 4 5 6 4 6 9 Cholesky factorization as explained above yields the sequence 0 0 0 0 A = 0 0 4 4 0 0 0 0 4 5 0 0 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Distributing copies of the identity matrix in the middle we arrive at 0 0 R = 0 0 0 0 0 Algorithm (Cholesky Factorization) initialize R = upper triangular part of A (including the diagonal) for k = : m end for j = k + : m end R(j, j : m) = R(j, j : m) R(k, j : m) R(k,j) R(k,k) R(k, k : m) = R(k, k : m)/ R(k, k) The operations count for the Cholesky algorithm can be computed as m m (m k + ) + ((m j + ) + ) = 3 m3 + m m k= j=k+ Thus the count is O( 3 m3 ), which is half the amount needed for the LU factorization Another nice feature of Cholesky factorization is that it is always stable even without pivoting 69

Remark The simplest (and cheapest) way to test whether a matrix is positive definite is to run Cholesky factorization it If the algorithm works it is, if not, it isn t The solution of Ax = b with Hermitian positive definite A is given by: Compute Cholesky factorization A = R R Solve the lower triangular system R y = b for y 3 Solve the upper triangular system Rx = y for x 70