Physics 6730 Assignment 2

For each of the following exercises create the specified files with your answer(s). Submit your homework using the course submit utility.


Exercise 1 Optimium polynomial approximation

Use the zeros of the Chebyshev polynomial T(8,x) as starting points for interpolating the function x exp(-x) on the interval [-1,1]. Use Maple to build the interpolating polynomial. The function PolynomialInterpolation can help. Here is the Maple procedure:
with(CurveFitting);
p := x -> PolynomialInterpolation([x1, x2, x3, x4, x5, x6,x7,x8],[y1, y2, y3, y4, y5, y6, y7, y8],x);
The first vector argument lists the eight zeros of T(8,x) and the second lists the values of y = x*exp(-x) at these same points. After you insert the values for the xi's and yi's, evaluate p(x) at few x values to be sure it is behaving correctly. Then plot the difference p(x) - x*exp(-x) on the interval [-1,1]. Then try evaluating the difference slightly outside this interval.

In your answer file optimum.txt describe what you observed.


Exercise 2 Experiments with Pade approximants

The Gamma function extends the factorial function from the integers to the complex plane. Maple knows it as GAMMA. Gamma(x) is defined (in Maple notation) as
    int(exp(-t)/t^(x+1),t=0..infinity)
Please see Maple for details. Note that Gamma(n+1) = n!.

The Gamma function has no zeros in the finite complex plane and has poles at all negative integers and zero. So it makes a good testing ground for Pade approximation.

  1. Find the (4,4) Pade rational function approximation for GAMMA(x) that matches a Taylor series expansion about x = 1. Note that Maple will do it for you. For help, use ?Pade. To access the Pade command directly, start with the command with(numapprox);. Maple will give you an analytic expression for the Pade approximation that runs on for a couple of screens. Use evalf to get a numeric expression.

    For better readability, normalize the coefficients of the polynomials in the numerator and denominator so the coefficient of x4 in the denominator is 1.

  2. Locate the poles in your approximation by finding all the real zeros of the denominator. Compare the locations with the exact expected locations.
  3. Locate the real zeros of the numerator (if any).
Please put your answers in a file pade.txt.

Exercise 3 Program of the week: Interpolation

This is a programming assignment that makes a comparison between the Neville iterated interpolation scheme based on polynomails and the Bulirsch-Stoer interpolation scheme based on rational functions. This time I have written the entire code for you, except for a few lines. You are merely asked to understand the method and code and make four changes in the two subroutines to complete it.

Although this exercise does not use Numerical Recipes code, we use the C++ datatypes . The C++ part of the exercise involves understanding the NR matrix and vector classes, which are very similar to the ones we used in PHYCS 6720.

Here are the components of the program:

File Purpose of procedure
interp.cc Main program.
neville.cc Does the Neville iteration
bulirsch_stoer.cc Does the Bulirsch-Stoer iteration.
Makefile Rule for compiling the above.

See ~p6730/examples/a02 for the nearly complete code. You are asked to complete the subroutines neville.cc and bulirsch_stoer.cc. The lines to be completed are indicated by comments bordered by //**************.

Please hand in the two files indicated in red above with your changes. We will supply the rest.


Exercise 4 Running your program.

This exercise uses the same interpolation example as an assignment in PHYCS 6720.

Use your program to generate an interpolation of the gamma function (the factorial function, defined for real x). Maple knows this function as GAMMA(x). A table of 21 values is provided in ~p6730/example/a02/gamma.
  1. For simplicity, first create a file with only the first 7 values in this table and use it as input. Run your program for the following values of x, calling for the table:
           x = 1.5
           x = 0.5
    
    Estimate the error from the change in the last diagonal element. Compare both methods with the exact result from Maple. In both cases discuss whether the estimated error gives a reasonable accounting for the difference between the interpolated (extrapolated) value and the exact answer.
  2. Then run your program with all 21 points, interpolating at the following values of x, asking only for the final result:
      
           x = 0.5
           x = -0.5
    
    Compare with the exact result in both cases and discuss in terms of the applicability of each method to such an extrapolation problem.
Put your answers in a file interp.txt.
This page is maintained by:
Carleton DeTar Mail Form
Last modified 12 January 2003