Midterm_sample_solutions

Midterm_sample_solutions - MAE 107 Computational Methods...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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)
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/11/2011 for the course MAE 107 taught by Professor Rottman during the Summer '08 term at UCSD.

Page1 / 6

Midterm_sample_solutions - MAE 107 Computational Methods...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online