Linear Methods of Applied Mathematics
Selected Solutions

(c) Copyright 1994-1997 by Evans M. Harrell II and James V. Herod.     All rights reserved.

Notes for the instructor.

This contains calculations and examples which correlate with chapter 4 of the WWW text by Harrell and Herod.

Students can be encouraged to cut and paste from this notebook to do homework.

Instructions

This notebook uses Mathematica  to perform calculations for Harrell and Herod's hypertext book, Linear Methods of Applied Mathematics.   The student needs only a basic knowledge of Mathematica  to use the notebook, which is designed both to show how to work problems in the text and to provide a template for using Mathematica  to work other problems of the student's own design.  

Calculations will be performed when the reader presses enter in a given calculation cell (bold print).  It is best to activate the cells in order, so that Mathematica  will be able to call on operators and functions defined in earlier cells.  Red color coding is used to warn the reader when a given calculation relies on an earlier one.

A useful substitution, which we shall often make, is:

TrigId = {Cos[Pi n_] -> (-1)^n, Sin[Pi n_] -> 0};

ExpId = {E^(I Pi k) -> (-1)^k,E^(-I Pi k) -> (-1)^k};

Exercise III.1.  (Find some Fourier series)

Find the Fourier (sine and cosine) series 
	Fourier sine series
	Fourier cosine series
	Fourier exponential series
on the interval 0 < x < L for the function  
        f(x) = x for 0 < x < L/2, otherwise 0.  
Discuss what happens if the series is evaluated outside the interval 0 < x < L.

We may as well suppose that L = 1; otherwise, simply replace x in what follows by x/L and then multiply the whole series by L.  We call on some formulae from the notebook for Chapter 4.  Because of the dual definition of f(x), it is best to modify those formulae rather than use them directly:

The full Fourier series

A0 = Integrate[x, {x,0,1/2}]

A[m_] = 2 Integrate[x Cos[2 m Pi x], {x,0,1/2}] /. TrigId

Notice that these are 0 when m is even, and otherwise -1/(m Pi)^2 .

B[n_] = 2 Integrate[x Sin[2 n Pi x], {x,0,1/2}] /. TrigId

FullSeries[x_,infinity_] := 1/8 -             Sum[(1/(m Pi)^2) Cos[2 m Pi x], {m,1,infinity,2}] +             Sum[((-1)^(n+1) /(2 n Pi)) Sin[2 n Pi x], {n,1,infinity}]

Plot[FullSeries[x,5], {x,0,1}]

On a larger interval, we have:

Plot[FullSeries[x,5], {x,-2,2}]

The Fourier sine series

There are only b terms, and the difference between these b's and the previous ones is that more frequencies are admitted:

Clear[B]

B[n_] = 2 Integrate[x Sin[n Pi x], {x,0,1/2}]

When n is odd, these cosine functions vanish, and the sine functions alternate in sign.  When n is even, the sine terms functions and the cosine functions alternate in sign.

SinSeries[x_,infinity_] := Sum[(2 (-1)^(m/2-1/2)/(m Pi)^2) Sin[m Pi x], {m,1,infinity,2}]+          Sum[((-1)^(1+n/2)/(n Pi)) Sin[n Pi x] , {n,2,infinity,2}]

Plot[SinSeries[x,5], {x,0,1}]

On a larger interval, we have:

Plot[SinSeries[x,5], {x,-2,2}]

The Fourier cosine series

There are only a terms, and the difference between these a's and the ones for the full Fourier series is that more frequencies are admitted:

A0 = Integrate[x, {x,0,1/2}]

Clear[A]

A[m_] = 2 Integrate[x Cos[m Pi x], {x,0,1/2}]

When n is odd, these cosine functions vanish, and the sine functions alternate in sign.  When n is even, the sine functions vanish and the cosine functions alternate in sign.

CosSeries[x_,infinity_] := 1/8 +             Sum[(-2 /(m1 Pi)^2) Cos[m1 Pi x], {m1,1,infinity}]+          Sum[(2 (-1)^(1+m2/2)/(m2 Pi)^2) Cos[m2 Pi x] , {m2,2,infinity,2}]  +          Sum[((-1)^(m3/2-1/2)/(m3 Pi)) Cos[m3 Pi x] , {m3,1,infinity,2}]

Plot[CosSeries[x,5], {x,0,1}]

On a larger interval, we have:

Plot[CosSeries[x,5], {x,-2,2}]

The complex exponential Fourier series

This is the same series as the full Fourier series, except for the complex notation and the way the terms are grouped.  If we wish to calculate the coefficients directly, we may do it with:

CC[k_] = Integrate[x Exp[2 I k Pi x], {x,0,1/2}] /. TrigId

Exercise IV.1.  If f is a real-valued function, the coefficients am and bn are real-valued.  What do you conclude from (4.8) about the coefficients ck in this case?  What can you conclude about the ck if f is an even function?  if f is an odd function?

Answer:

If f is an even, real-valued function, then ck is real and even in k (that is, c-k = ck).  If f is an odd, real-valued function, then ck is imaginary and odd in k (that is, c-k = -ck).

Exercise IV.2.  Calculate the Fourier series for the saw-tooth function you get as the periodic extension of f(x) := 1 - |x| from the basic interval [-1,1].  Differentiate the series term by term and compare with the Fourier series for the derivative of f(x).  Notice that the Fourier series is not bothered by the corners in the function at -1,0, and 1.

Since the saw-tooth function is even, this series is the same as the Fourier cosine series for the function 1 - x on the interval [0,1]:

Fourier cosine series

Here we set up some Mathematica  commands to compute the Fourier cosine series.

Ave[f_, {a_,b_}] := (1/(b-a)) Integrate[(f /. x -> intvar1),                        {intvar1, a, b}]
AC[f_,m_, {a_,b_}] := (2/(b-a)) Integrate[              (Cos[m Pi intvar2/(b-a)] f /. x -> intvar2),               {intvar2, a, b}]  /. TrigId

CosSeries[f_, NN_, {x_,a_,b_}] := Ave[f,{a,b}] +       Sum[AC[f,m,{a,b}] Cos[m Pi x/(b-a)], {m, 1, NN}]

CosSeries[1 - x, 5, {x,0,1}]

If we differentiate this term by term, we indeed get the Fourier sine series for -1, which you may think of as a square pulse, when it is extended outside this interval.

Exercise V.2.  What series do you obtain by differentiating the Fourier series for the square pulse (cf. model problem IV.1)?  If you know about the Dirac delta function, comment on the relationship between the series you get for the square pulse and the one for the delta function d(x-a) (periodically extended).

Answer:

We get the series

DiffSeries[x_,infinity_] := 4 Sum[Cos[2 n Pi x], {n,1,infinity,2}]

This sum includes odd terms only.  Although the derivative of the square pulse is 0 for almost every x, and this sum is divergent, it still makes sense as an approximation to a differentiable function with a steep slope at 1/2:

Plot[DiffSeries[x,12], {x,0,1}]

Exercise V.3.  Consider what happens when a Legendre series is differentiated term by term.  Is the result a Legendre series?  Does the result converge to the derivative of the original function?

The result is still a polynomial series, but it is not written in the form of a Legendre series.   It will be equivalent to the Legendre series for the derivative whenever the function and its derivative are continuous.