Scientific Computing, Spring 1999 (http://www.math.nyu.edu/faculty/goodman/teaching/sci comp 99/)

Assignment 2.

Given January 26, due February 9.

We want to study the function

f(x) = ∫_{0}^{1} cos (xt^{2}) dt .  (1)

Step 1: Write a program to estimate f(x) using a panel integration method. The program should be modular, well documented, robust, and clean. At the lowest level should be a procedure that takes as input x and n = 1/Δt and returns the approximate integral with that x and Δt value. This routine should be written so that another person could easily substitute a different panel method by changing a few lines of code.

Step 2: Verify the correctness of the program by checking that it gives the right answer for small x. We can estimate f(x) for small x using a few terms of its Taylor series. This series can be computed by integrating the Taylor series for cos(xt^{2}) term by term.

Step 3: With x = 1, do a convergence study to verify the second order accuracy of the trapezoid rule and the fourth order accuracy of Simpson’s rule.

Step 4: Write a routine that uses the routine from Step 1 and Richardson estimation to find an n that gives f(x) to within a specified error tolerance. The input should be x and the desired error bound. The output should be the estimated value of f and the number of points used. This routine should be robust enough to quit and report failure if it is unable to achieve the requested accuracy.

Step 5: For large x we have the approximation

f(x) ∼ \sqrt{\frac{π}{8x}} + \frac{1}{2x} sin(x) − \frac{1}{16x^{2}} cos(x) + · · · .  (2)

Make a few plots showing f and its approximations using one, two and all three terms on the right side of (2) for x in the range 1 ≤ x ≤ 1000. In all cases we want to evaluate f so accurately that the error in our f value is much less than the error of the approximation (2). Note that even for a fixed level of accuracy, more points are needed for large x. Why?