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

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

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

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2008 for the course CS 257 taught by Professor Thomaskerkhoven during the Fall '05 term at University of Illinois at Urbana–Champaign.

Page1 / 3

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

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

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