hw9 - f ( π/ 6) using this scheme and indicate the order...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Due: November 6, 2008 CS 257 (Luke Olson): Homework #9 Problem 1 Problem 1 We are coding for a particle physics team and asked to compute the mass of a region with density ρ = ln ( x ) x - 1 . That is, compute m = Z 1 0 ρ ( x ) dx. We convince the team use n -point Gauss Quadrature, praising its ability to achieve spectral convergence as n increases. Is this a good idea in this situation? Why not Newton-Cotes? Use int gauss.m and hand in a plot (with code) of n versus error along with comments on the outcome . ( hint: the integral should be π 2 / 6 . See dilog and polylogarithm in Wikipedia for more information ). Problem 2 The same team of scientists uses a difference scheme f 0 ( x ) 1 2 h [4 f ( x + h ) - 3 f ( x ) - f ( x + 2 h )] in many of their calculations. Using f ( x ) = cos ( x ) as a test case, approximate
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: f ( π/ 6) using this scheme and indicate the order of convergence (i.e. what is p in | f ( pi/ 6)-approx | = ch p . Use the ratio of p = | e k | | e k +1 | for this estimate). Hand-in code, and estimate of p , and the following table. h approx df exact df error ratio 1/10 1/20 1/40 1/80 1/160 1/320 1/640 The following printline in Matlab may help printing the table: 1 fprintf ( ’%-10s %-10s %-10s %-10s %-10s\n’ , ’h’ , ’approx df’ , ’exact df’ , ’error’ , ’ratio’ ); 2 fprintf ( ’%-10s %-10g %-10g %-10.2g %-10.2g\n’ ,strtrim( rats (h)),df,dfexact,err(j),ratio); Page 1 of 1...
View Full Document

This note was uploaded on 07/10/2011 for the course CS 257 taught by Professor Olson during the Spring '08 term at University of Illinois, Urbana Champaign.

Ask a homework question - tutors are online