Homework 3
1) Derive Eq. (2.45) in Pang's book (the "five-point formula"). Also,
derive the cubic extrapolation for the boundary points f '(x_1), f '(x_2), f
'(x_{n-1}), f '(x_n) and the second derivatives at these points, e.g. up to
order O(h^4). Use these results to solve Solve T. Pang, Problem 2.6. You can
modify the corresponding program given on Pang's webpage. Run it for N=11, and
create a table of x_i, f(x_i), f '(x_i), f ''(x_i) with i=1, ...,N. Compare
this to the same table for the three-point formula. Please also hand in a
printout of your program. (50 points)
2)Write a simple integration program which uses Pang's Eq. 2.48 (not Simpson's
rule) to integrate the function f(x)=Exp(-x) from x=0 to x=20. (This is almost
equivalent to integrating the function from 0 to infinity.) If you use 10
equally spaced integration slices of length h=2.0 (corresponding to 11 data
points), the routine should give you the (rather bad) approximate result
1.31303525 for the integral. If you use 100 equally spaced slices of length
h=0.2 you get 1.00333071. Verify these results with your program. Then use a
nonuniform mesh, x_i=i*h*exp(0.01*i), for the integration. Use again 100
slices, but take care in the integration steps because now (x_{i+1)-x_i) is not
a constant anymore. Also, h=20./(N-1) is changed to
h=(20./(N-1))*exp(-0.01*(N-1)). This should improve the accuracy of the
integral by one order of magnitude. Compare your results with the analytical solution.
Please also hand in a printout of your program. (50 points)