CHOLESKY FACTORIZATION Applied Numerical Methods with MATLAB fo

EXAMPLE 10.5 Cholesky Factorization Problem Statement. Compute the Cholesky factorization for the symmetric matrix [ A] = 6 15 55 15 55 225 55 225 979 Solution. For the first row i = 1, Eq. 10.15 is employed to compute u 11 = √ a 11 = √ 6 = 2.44949 Then, Eq. 10.16 can be used to determine u 12 = a 12 u 11 = 15 2.44949 = 6.123724 u 13 = a 13 u 11 = 55 2.44949 = 22.45366 For the second row i = 2: u 22 = a 22 − u 2 12 = 55 − 6.123724 2 = 4.1833 u 23 = a 23 − u 12 u 13 u 22 = 225 − 6.12372422.45366 4.1833 = 20.9165 For the third row i = 3: u 33 = a 33 − u 2 13 − u 2 23 = 979 − 22.45366 2 − 20.9165 2 = 6.110101 Thus, the Cholesky factorization yields [U ] = 2.44949 6.123724 22.45366 4.1833 20.9165 6.110101 The validity of this factorization can be verified by substituting it and its transpose into Eq. 10.14 to see if their product yields the original matrix [A]. This is left for an exercise. After obtaining the factorization, it can be used to determine a solution for a right- hand-side vector {b} in a manner similar to LU factorization. First, an intermediate vector {d} is created by solving [U ] T {d} = {b} 10.17 Then, the final solution can be obtained by solving [U ]{x} = {d} 10.18

10.3.1 MATLAB Function:

chol MATLAB has a built-in function chol that generates the Cholesky factorization. It has the general syntax, U = cholX where U is an upper triangular matrix so that U U = X . The following example shows how it can be employed to generate both the factorization and a solution for the same matrix that we looked at in the previous example. EXAMPLE 10.6 Cholesky Factorization with MATLAB Problem Statement. Use MATLAB to compute the Cholesky factorization for the same matrix we analyzed in Example 10.5. [ A] = 6 15 55 15 55 225 55 225 979 Also obtain a solution for a right-hand-side vector that is the sum of the rows of [A]. Note that for this case, the answer will be a vector of ones. Solution. The matrix is entered in standard fashion as A = [6 15 55; 15 55 225; 55 225 979]; A right-hand-side vector that is the sum of the rows of [A] can be generated as b = [sumA1,:; sumA2,:; sumA3,:] b = 76 295 1259 Next, the Cholesky factorization can be computed with U = cholA U = 2.4495 6.1237 22.4537 4.1833 20.9165 6.1101 We can test that this is correct by computing the original matrix as UU ans = 6.0000 15.0000 55.0000 15.0000 55.0000 225.0000 55.0000 225.0000 979.0000 10.3 CHOLESKY FACTORIZATION 265 To generate the solution, we first compute d = U\b d = 31.0269 25.0998 6.1101 And then use this result to compute the solution x = U\d x = 1.0000 1.0000 1.0000

10.4 MATLAB LEFT DIVISION

We previously introduced left division without any explanation of how it works. Now that we have some background on matrix solution techniques, we can provide a simplified description of its operation. When we implement left division with the backslash operator, MATLAB invokes a highly sophisticated algorithm to obtain a solution. In essence, MATLAB examines the structure of the coefficient matrix and then implements an optimal method to obtain the solution. Although the details of the algorithm are beyond our scope, a simplified overview can be outlined. First, MATLAB checks to see whether [A] is in a format where a solution can be obtained without full Gauss elimination. These include systems that are a sparse and banded, b triangular or easily transformed into triangular form, or c symmetric. If any of these cases are detected, the solution is obtained with the efficient techniques that are available for such systems. Some of the techniques include banded solvers, back and for- ward substitution, and Cholesky factorization. If none of these simplified solutions are possible and the matrix is square, 2 a general triangular factorization is computed by Gauss elimination with partial pivoting and the solution obtained with substitution. 2 It should be noted that in the event that [A] is not square, a least-squares solution is obtained with an approach called QR factorization. PROBLEMS 267 PROBLEMS 10.1 Determine the total flops as a function of the number of equations n for the a factorization, b forward substitu- tion, and c back substitution phases of the LU factorization version of Gauss elimination. 10.2 Use the rules of matrix multiplication to prove that Eqs. 10.7 and 10.8 follow from Eq. 10.6. 10.3 Use naive Gauss elimination to factor the following system according to the description in Section 10.2: 7x 1 + 2x 2 − 3x 3 = − 12 2x 1 + 5x 2 − 3x 3 = − 20 x 1 − x 2 − 6x 3 = − 26 Then, multiply the resulting [L] and [U] matrices to deter- mine that [A] is produced.

10.4 a

Use LU factorization to solve the system of equations in Prob. 10.3. Show all the steps in the computation. b Also solve the system for an alternative right-hand-side vector {b} T = ⌊ 12 18 − 6⌋ 10.5 Solve the following system of equations using LU factorization with partial pivoting: 2x 1 − 6x 2 − x 3 = − 38 − 3x 1 − x 2 + 6x 3 = − 34 − 8x 1 + x 2 − 2x 3 = − 40 10.6 Develop your own M-file to determine the LU factoriza- tion of a square matrix without partial pivoting. That is, de- velop a function that is passed the square matrix and returns the triangular matrices [L] and [U]. Test your function by using it to solve the system in Prob. 10.3. Confirm that your function is working properly by verifying that [L][U ] = [ A] and by using the built-in function lu . 10.7 Confirm the validity of the Cholesky factorization of Example 10.5 by substituting the results into Eq. 10.14 to verify that the product of [U] T and [U] yields [A].

10.8 a

Perform a Cholesky factorization of the following symmetric system by hand: ⎡ ⎣ 8 20 16 20 80 50 16 50 60 ⎤ ⎦ ⎧ ⎨ ⎩ x 1 x 2 x 3 ⎫ ⎬ ⎭ = ⎧ ⎨ ⎩ 100 250 100 ⎫ ⎬ ⎭ b Verify your hand calculation with the built-in chol function. c Employ the results of the factorization [U] to determine the solution for the right-hand-side vector. 10.9 Develop your own M-file to determine the Cholesky factorization of a symmetric matrix without pivoting. That is, develop a function that is passed the symmetric matrix and returns the matrix [U]. Test your function by using it to solve the system in Prob. 10.8 and use the built-in function chol to confirm that your function is working properly. 10.10 Solve the following set of equations with LU factor- ization with pivoting: 3x 1 − 2x 2 + x 3 = − 10 2x 1 + 6x 2 − 4x 3 = 44 − 8x 1 − 2x 2 + 5x 3 = − 26

10.11 a

Determine the LU factorization without pivoting by hand for the following matrix and check your results by validating that [L][U] = [A]. ⎡ ⎣ 8 5 1 3 7 4 2 3 9 ⎤ ⎦ b Employ the result of a to compute the determinant. c Repeat a and b using MATLAB.

10.12 Use the following LU factorization to a compute

the determinant and b solve [A]{x} = {b} with {b} T = ⌊− 10 50 − 26⌋. [ A] = [L][U ] = ⎡ ⎣ 1 0.6667 1 − 0.3333 − 0.3636 1 ⎤ ⎦ × ⎡ ⎣ 3 − 2 1 7.3333 − 4.6667 3.6364 ⎤ ⎦ 10.13 Use Cholesky factorization to determine [U] so that [ A] = [U ] T [U ] = ⎡ ⎣ 2 − 1 − 1 2 − 1 − 1 2 ⎤ ⎦ 10.14 Compute the Cholesky factorization of [ A] = ⎡ ⎣ 9 25 16 ⎤ ⎦ Do your results make sense in terms of Eqs. 10.15 and 10.16?