MCS 471 Project Four due Wednesday 16 November 2005
| > | restart; |
The goal of this project is to study the use of Chebyshev polynomials to approximate functions.
0. Chebyshev Series in Maple
The Chebyshev polynomials are available as the procedure "T" in the package orthopoly, loaded into a Maple worksheet by
| > | with(orthopoly,T): |
To get the fifth degree Chebyshev polynomial in x we type
| > | T(5,x); |
Chebyshev polynomials form an orthonormal basis with respect to the following innner product:
| > | sym_ip := (f,g) -> int(f*g/sqrt(1-x^2),x=-1..1)*2/Pi; # symbolic |
| > | num_ip := (f,g) -> evalf(Int(f*g/sqrt(1-x^2),x=-1..1)*2/Pi); |
The functions "sym_ip" and "num_ip" are symbolic and numerical implementations of this inner product. The symbolic implementation is good to illustrate theoretical properties, but limited in its application. In practice, we will mostly use "num_ip".
The function "num_ip" takes on input two expressions in x and computes numerically a definite integral.
Just to verify the orthogonality, we let Maple compute all inner products of all Chebyshev polynomials of degree 1 to 3.
| > | Matrix(3,3,(i,j) -> sym_ip(T(i,x),T(j,x))); |
| > | Matrix(3,3,(i,j) -> num_ip(T(i,x),T(j,x))); # this goes faster |
Consider a general polynomial of degree 4 in the Chebyshev basis:
| > | p := a[0]/2+sum(a[i]*T(i,x),i=1..4); |
The division by 2 of a[0] will become apparent soon.
Our problem is to determine the unknown coefficients a[i] of p, i=0..4, so that p approximates exp(x) in the least squares sense.
Computing a least squares approximation is geometrically equivalent to projecting onto the basis.
We first show how to implement this projection symbolically:
| > | sym_prj := (f,n) -> seq(sym_ip(f,T(i,x)),i=0..n); |
| > | sym_prj(p,4); |
Because of the orthogonality, the projection of p in the Chebyshev basis equals its coefficients, just like in a geometric coordinate system. If we approximate the exp(x), we compute the following inner products:
| > | sym_prj(exp(x),4); |
As there is no symbolic antiderivative for these integrals, Maple cannot evaluate the symbolic projection. Therefore, we use the numerical inner product to compute the projection of exp(x) on the Chebyshev basis:
| > | num_prj := (f,n) -> seq(num_ip(f,T(i,x)),i=0..n); |
| > | c := num_prj(exp(x),4); |
| > | chb := c -> c[1]/2 + sum(c[i]*T(i-1,x),i=2..nops(c)); |
| > | cp := chb([c]); |
The polynomial cp is a truncated Chebyshev series
| > | plot_f := plot(exp(x),x=-1..1,color=black): |
| > | plot_p := plot(cp,x=-1..1,color=red): |
| > | plots[display](plot_f,plot_p); |
![[Plot]](images/chebapprox_14.gif)
On the plot we do not see the difference between the given function exp(x) and the Chebyshev approximation.
Typical for a least sqaure solution, we have that the error exp(x) - cp is perpendicular to the basis:
| > | e := exp(x) - cp; # error |
| > | num_prj(e,4); |
The plot of the error show the typical oscillations of a uniformly bounded Chebyshev approximation.
| > | plot(e,x=-1..1); |
![[Plot]](images/chebapprox_17.gif)
| > |
1. The Accuracy of the Chebyshev Approximations
In the example we have seen that already with a fourth degree polynomial we obtain a very accurate approximation for exp(x). The purpose of the next assignment is to verify the decrease in coefficient size as the degree of the approximation increases.
Assignment One
Compute Chebyshev approximations for exp(x) with polynomials of degree n, for n ranging from 4 to 13.
Make a table with two columns: first the degree n, and then the highest degree coefficient of p, in scientific format with four significant decimal places.
Describe the relationship between the degree n and the magnitude of the highest degree coefficient of p.
2. Chebyshev Approximations over General Intervals
While we use the standard interval [-1,+1], we can compute Chebyshev approximations over any finite interval.
The purpose of the next assignment is that you figure out a coordinate transformation which maps [a,b] into [-1,+1], so we can approximate function f(t), for t in [a,b].
Assignment Two
Compute a Chebyshev approximation for exp(x) over the interval [1,5] with a degree n high enough so the error is below 1.0e-6 everywhere on the interval [1,5]. Verify the least squares property of the solution.
3. Chebyshev Approximations of Periodic Functions
As the Chebyshev polynomials are defined via the cosine, we could expect Chebyshev approximations to be very suitable to approximate periodic functions.
Assignment Three
Consider f(x) = 4*sin(2*Pi*x) +3*sin(5*Pi*x) over the interval [-1,+1]. Compute a Chebyshev approximation with a degree high enough so the error is below 1.0e-6 everywhere on [-1,+1]. Describe the quality of the approximation.
In particular, describe the approximation when we replace every sin() in f(x) by cos().
4. Chebyshev Approximations of Discontinous Functions
If the function we approximate has a discontinuous jump somewhere
inside the interval [-1,+1],
does the Chebyshev approximation then converge as the degrees increase?
The purpose of the next assignment is to find out.
Assignment Four
Consider the function f(x) defined as follows: f(x) = -1 for x < 0, f(0) = 0, and f(x) = +1 for x > 0.
Compute Chebyshev approximations for increasing degrees and observe the behaviour of the error function.
Can you get the error as low as you like?
5. The deadline is Wednesday 16 November at 3PM
Bring your solution to the project to class. The your is emphasized to stress that your solution is the result of an individual effort. Collaborations are NOT permitted.
Your solution should contain the following:
1. Answers to the questions in the assignments. Please write complete grammatically correct sentences.
2. Tables summarizing the numerical experiments you have done.
3. A print out of the Maple worksheet to show the set up of your calculations may be included as an appendix. Suppress long output with colons.
Do not eMail me Maple worksheets. Also, summarize your calculations, it is not necessary to print out every single case you computed.
If you have questions or difficulties with the assignments, feel free to come to my office for help.