Numerical Methods, MAT 350
Autumn 2001
Homework: Legendre Polynomials
Due by class, Wednesday October 31
In class, we discussed the use of orthogonal polynomials in
numerical integration. This is a short assignment intended
to give you some practice using orthogonal polynomials.
Let Pn(x) be the n-th order
Legendre polynomial. Here is what you have to do:
- By hand, find P5(x) using the recursion formula,
starting with P0(x) and P1(x).
Check your result by comparing it to a reference book.
- By hand, evaluate P5(x) for
x = 0, 0.25, 0.5, 0.75, and 1.
- By hand, use the inner
product formula to verify that P5(x) and
P3(x) are orthogonal.
- Write a subroutine that calculates Pn(x)
using the recursion formula.
There are two basic strategies that
one can follow: One is that the routine calls itself
recursively. The other is to use two variables to store
P0(x),
P1(x), et cetera
and loopsthrough increasing values of n.
- The subroutine should take x and n
as arguements.
- In your code, you should have comment statements explaining
the role of each of the variables along with an explanation of
how the routine works.
- Test this routine by using it to calculate
P5(x) for
x = 0, 0.25, 0.5, 0.75, 1. Compare with the results
done by hand.
- Use your subroutine to graph both P9(x)
and P10(x)
versus x on the interval [-1,1].
Use lots of plot points to get nice smooth graphs.
- Does your graph illustrate the interleaving property?
Explain.