{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Midterm_sample_solutions

# Midterm_sample_solutions - MAE 107 Computational Methods...

This preview shows pages 1–3. Sign up to view the full content.

MAE 107 – Computational Methods Summer Session II 2009 Midterm sample – Solutions Problem 1 function fact=factorial(n) % Computes the factorial of n for an integer n positive if(n<0) error(’n must be a positive integer’) end fact=1; for k=1:n, fact=fact*k; end Note that the previous function, indeed computes n ! for n 0. In particular for n = 0, the for...end loop is never started as [1:n] does not have any element. Problem 2 Consider the matrix A = 2 - 1 3 - 2 - 2 - 2 2 - 7 4 . 1. The first step of the Forward Elimination procedure aims at canceling the coefficients below the pivot coefficient a 11 = 2 in the first column of A . To do so, we perform the following row operations: - (2) (2) - λ 21 (1) with λ 21 = - 1, - (3) (3) - λ 31 (1) with λ 31 = 1. The result of this operation can be written as a decomposition for A : A = 1 0 0 - 1 1 0 1 0 1 2 - 1 3 0 - 3 1 0 - 6 1 | {z } A (1) The second step of the Forward Elimination procedure aims at canceling the coefficients below the second pivot coefficient a 22 = - 3 in the second column of the modified A (1) . The following row 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
operation is performed (3) (3) - λ 32 (2) with λ 32 = 2. The result of this operation can be written as the following decomposition for A (1) : A (1) = 1 0 0 0 1 0 0 2 1 2 - 1 3 0 - 3 1 0 0 - 1 From these two steps we can write: A = 1 0 0 - 1 1 0 1 0 1 1 0 0 0 1 0 0 2 1 2 - 1 3 0 - 3 1 0 0 - 1 = 1 0 0 - 1 1 0 1 2 1 2 - 1 3 0 - 3 1 0 0 - 1 The LU decomposition of A is therefore: A = L · U , with L = 1 0 0 - 1 1 0 1 2 1 and U = 2 - 1 3 0 - 3 1 0 0 - 1 . 2. Using the fundamental property of the determinant, the determinant of A is the product of the determinants of L and of U . These two matrices are diagonal, therefore their determinants are easily computed as the product of their diagonal terms. | L | = 1 and | U | = 6, therefore | A | = 6 3. To compute Y = A - 1 we need to solve 3 linear systems for the column vectors y (1) , y (2) and y (3) , which are the columns of Y : Ay (1) = 1 0 0 , Ay (2) = 0 1 0 , Ay (3) = 0 0 1 .
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern