{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hw5_solutions - CS 257 Numerical Methods Homework 5 October...

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

CS 257 Numerical Methods - Homework 5 October 3, 2006 1. [1pt] 7.3 #2 (a) Solution: 5( n - 1) + 1 = 5 n - 4. The important part is that the number of operations is O ( n ). (b) Solution: 8( n - 2) + 6 + 3( n - 2) = 11 n - 16. 2. [2pt] 7.3c #5. Turn in your implementation of Tri() . function x=tri(a,d,c,b) n = length(d); for i=2:n xmult = a(i-1) / d(i-1); d(i) = d(i) - xmult*c(i-1); b(i) = b(i) - xmult*b(i-1); end x(n) = b(n)/d(n) for i=(n-1):-1:1 x(i) = (b(i) - c(i)*x(i+1))/ d(i); end Run with the following data a = ones(99,1); a(99) = -1; d = -4*ones(100,1); d(1) = 4; d(100) = 4; c = ones(99,1); c(1) = -1; b = 40*ones(100,1); b(1) = -20; b(100) = -20; x = tri(a,d,c,b) 3. [1pt] 8.1 #1a Solution: L = 1 0 0 0 1 0 1 / 3 - 3 1 U = 3 0 3 0 - 1 3 0 0 8 4. [1pt] 8.1 #9 Solution: L = 1 0 0 1 1 0 3 - 1 1 D = 2 0 0 0 - 2 0 0 0 3 U = 1 - 1 / 2 1 0 1 - 1 / 2 0 0 1 x = - 1 2 1 5. [1pt] 8.1 #21 L = 1 0 0 0 2 1 0 0 - 1 2 1 0 1 - 1 1 1 D = 1 0 0 0 0 - 1 0 0 0 0 2 0 0 0 0 - 2 1

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

View Full Document
6. [1pt] 8.1 #22 L = 2 0 0 3 4 0 5 1 6 7. [Optional 0pt] (a) Write a MATLAB function [L,U]=ludoo(A) that implements LU using the Doolittle implementation (cf. pg. 320).
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 3

hw5_solutions - CS 257 Numerical Methods Homework 5 October...

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

View Full Document
Ask a homework question - tutors are online