Mathematics 373 – Applied Mathematics (PDE) Lab/Demonstration 1 – Fourier Series February 22, 2001

Background

On Tuesday, we introduced the Fourier series of a function f(x) on [−L, L]:

(1)  a_{0}/2 + ∑_{n=1}^{∞} (a_{n} cos (\frac{nπx}{L}) + b_{n} sin (\frac{nπx}{L}))

where:

\{ \begin{matrix}a_{n} = \frac{1}{L} ∫_{−L}^{L} f(x) cos (\frac{nπx}{L}) dx & if n ≥ 0 \\ b_{n} = \frac{1}{L} ∫_{−L}^{L} f(x) sin (\frac{nπx}{L}) dx & for n ≥ 1 \end{matrix}

In this lab, you will compute Fourier series for several functions using Maple, plot partial sums of the Fourier series together with the function, and observe some patterns. Because you will be working on the Midterm Problem Set this coming week, I will not ask you to turn in an assignment based on this lab. However some of the Midterm problems will involve using Maple in ways similar to what you do today. So you will want to generate a commented worksheet based on the examples below for your own reference. There is a worksheet with additional examples on the course homepage.

Lab Activities

I. A First Example – the “sawtooth function” – the reason for the name will become clear in part B below. Let f(x) = x on [−1, 1] (L = 1). This is clearly piecewise continuous! The Fourier coefficients can be computed in Maple as follows. First enter the command

                            assume(n,integer);

Then as in the handout from class on Tuesday, we can define functions a and b that return the values of the Fourier coefficients as formulas in n:

                   a := n -> int(x*cos(n*Pi*x),x=-1..1);
                   b := n -> int(x*sin(n*Pi*x),x=-1..1);

Enter these definitions. You can see the formulas for the Fourier coefficients by entering commands

                                a(n); b(n);

One batch of these is always zero. Explain how we could have known this.

Next, we can define a function that will compute a given partial sum

a_{0}/2 + ∑_{n=1}^{N} (a_{n} cos(nπx) + b_{n} sin(nπx))

of the Fourier series for our function:

 PSFS := (N,x) -> a(0)/2 + sum(a(n)*cos(n*Pi*x)+b(n)*sin(n*Pi*x),n=1..N);

Note, this uses the general formula (1) given above. In cases like the one we are working with here, where one set of coefficients is automatically zero, we could also leave those terms out. To plot the N = 5 partial sum together with f for x ∈ [−1, 1], use

                       plot({x,PSFS(5,x)},x=-1..1);

A) Increase N to 10,15,20 and generate new plots of the corresponding partial sums of the Fourier series, together with f. What seems to be happening as N increases? Pay special attention to the partial sums near the endpoints of the interval (x = −1, 1).

B) Now plot the function f together with the partial sum with N = 20 on the larger

interval [−4, 4]. Why must f and the Fourier series be different on this larger interval? C) Take N even larger if necessary, and describe the function to which the partial sums

of the Fourier series seem to be converging on [−4, 4]. D) What does the Fourier series appear to be doing at x = …, −3, −1, 1, 3, … where the

function obtained from f by repeating the portion of the graph in [−1, 1] in intervals of length 2 (called the “periodic extension” of f) has jump discontinuities?

II. Investigate the partial sums of the Fourier series for f(x) = cos(x) on [−1, 1], and also on the larger interval [−4, 4]. Which features of this example are similar to what you saw in I? Which features are different?

III. Repeat question I for the function

f(x) = \{ \begin{matrix}e^{−x} & if −1/2 ≤ x ≤ 1/2 \\ 0 & if |x| > 1/2 \end{matrix}

You will need first to figure out how to compute the Fourier coefficients. (The function f can be defined using the piecewise command in Maple. Look this up in the online help for more info.) What is happening at the points −1/2, 1/2, where the function f itself has jump discontinuities?