# Assignment B

You will write a Python script containing a function called chebexpansion which computes a Chebyshev polynomial approximation to any function we specify. Specifically your function will satisfy the following criteria.

• Your function will require three arguments: the function to be approximated; the degree of the polynomial approximate; and a vector of points where the polynomial is to be evaluated. Thus, to run your function we will be able to type something like: chebexpansion(sin,9,array([-1,0,1])).
• Your function will have one output: a vector of values of the polynomial at the points given in the input x. Thus, in the previous example, the output would be an array [p(-1),p(0),p(1)], where p is the Chebyshev polynomial approximation you calculated.
• Your function can call a function provided in this file to calculate the coefficients of the expansion in Chebyshev polynomials. In other words, your polynomial will be $\sum_{k=0}^K a_kT_k(x),$ where $$K$$ is the number you gave as a second argument to your function, $$x$$ is essentially the vector you gave as the third argument, and $$a_k$$ is calculated by the little function we provide. Note that the Chebyshev polynomials of the first kind $$T_k$$ may be computed using another function defined in that file, chebyshevT(d,x) where d is the degree of the Chebyshev basis polynomial, and x is the array of x coordinates (same as above).

Once your function is working, you will use it to plot Chebyshev polynomial approximations of degree 20 to two functions: the name function you created in Assignment A; and the function $\text{step}(x)=\begin{cases} -1 & x<0\\ 1 & x \ge 0. \end{cases}$ The plots will look something like that in Figure 1. Observe the following things about the plots.

Figure 1: Chebyshev approximation to the Ahz function.
• They will not have a title. Insted, you will provide captions.
• The axes are labeled.
• The curves are different colors. It does not matter what colors you choose.
• The plot has a legend. For an example of how to do that, see the feedback from Assignment A.

Once you have the program working, you will save the two images, and write a paper around them. The paper will be done in LaTeX, and will discuss the practical application of Chebyshev polynomial approximation, including the method for computing the coefficients. In discussing the coefficients, you will present the mathematics - there is no interest in a discussion of the Python function you were given. You will obviously present the coefficients you calculated in each case, and discuss the figures you generated. Equally obviously, you will discuss the nature of the results you see for the discontinuous function. If the words "Gibbs phenomenon" were to appear in your paper, that would not be a bad thing (unless, of course. those words were not explained). Remember that there are hints for mathematical writing in Assignment 6 and in the style document.

You will turn in two things for this assignment: the Python script; and the PDF copy of the paper you wrote. For emphasis, this time we want the PDF copy - you do not need to send the .tex file unless you want to. The assignment is turned in when the two files containing the script and paper are received as attachments to an email message in the instructor's inbox. The assignment is worth 60 points, and is due at 8 AM on Tuesday, 12 December.

Assignment 6 is posted.

The midterm exam will take place on Friday, 12 October. As always, you are permitted any paper notes you find useful, but no electronic devices are allowed. The test is cumulative, but emphasizes the material covered in the last fours weeks. A sample exam is available.

You need to install Matlab on your computer by Wednesday. You do not need Simulink or any particular toolboxes, though you might find the Symbolic toolbox useful at some time in the future (not in this class).

Department of Mathematics, PO Box 643113, Neill Hall 103, Washington State University, Pullman WA 99164-3113, 509-335-3926, Contact Us