Linear Methods of Applied Mathematics
Calculations of some Fourier series

The Method of d'Alembert

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

Acknowledgment.  We are grateful to Alfred D. Andrew for contributions which have been incorporated into this notebook.

Notes for the instructor.

This contains calculations and examples which correlate with chapter 7 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.

As in the preceding chapter, we define the wave operator by:

WaveOp[f_,c_] := (1/c^2) D[f, {t,2}] -  D[f, {x,2}]

The wave equation is the statement that the unknown, u, is in the null space of this operator.  We'll often set c = 1 for convenience , so let's also define

WaveOp[f_] := WaveOp[f,1]

d'Alembert's solution of the wave equation.  

Derivation and discussion.

Let's test out the wave operator on a couple of instructive functions.  We set c=1 fot this discussion.

WaveOp[Sin[t - x]]

WaveOp[Sin[Exp[Cos[x-t]]]]

This can't be a coincidence!  In fact, early in the nineteenth century, d'Alembert realized that if f is any  function depending on the combination x-t, WaveOp[f] is automatically zero:

WaveOp[Phi[x + t]]

The same is true for any function of x+t:

WaveOp[Psi[x - t]]

Even better:

WaveOp[Phi[x + t] + Psi[x - t]]

Since the wave equation is linear, given any two twice differentiable functions of a single variable, the expression f[x+ct]+ y[x-ct] is also a solution.   D'Alembert had the insight that not only is f[x+ct]+ y[x-ct] a solution, it is the general solution.  To understand this we need to think about how f and y could be determined in specific cases.

Suppose now that we have an infinitely long string, and initial conditions of the usual form:
                    u[0,x] = f[x]
                    ut[0,x] = g[x].
                    
Here there are no boundary conditions to impose, since we let x run to infnity in both directions.


How do we find a solution of the form u[t,x] = Phi[x+ct]+ Psi[x-ct] which solves this problem?  

Suppose first that g[x] := 0.  Then, as in the text, we substitute and find that:
                  f[x] = y[x] = f[x]/2.

Example

Suppose that f[x] is a function with one bump near x=0 such as 
Exp[-x^2], and there is no initial velocity.  e would see the bump break into the superposition of two bumps of half the height, one moving to the right and one to the left.

Table[Plot[Exp[-(x+n*.3)^2] /2 + Exp[-(x-n*.3)^2]  /2, 
{x, -4, 4}, PlotRange -> {-.1,1}], {n,0,10}]

(You can animate these plots and watch the wave move.)

Next, let's turn the tables and suppose that f[x] = 0  but g[x]  0.  As in the text, we learn that: Psi[x] = - Phi[x], and 
       Phi[x] = Integrate[g[x], x] 
Consequently, the solution to (WE) with these IC is

u2[g_,t_,x_] := (1/2) Integrate[(g /. x -> z), {z,x - t, x + t}]

If, for example,

g[x_] := x/(1 + x + x^2)

u2[g[x],t,x]

Table[Plot[%, 
{x, -10, 10}, PlotRange -> {-5,5}], {t,1,6}]

Automating the general solution

We can try to write the general solution as follows.

Clear[u]
Clear[f]
Clear[g]

The general solution (with arbitrary c) is:

u[c_,f_,g_,t_,x_] :=           (1/2) (f[x + c t] + f[x - c t])           + (1/(2 c)) Integrate[g[x1], {x1,x - c t, x + c t}]

Model Problem VII.2

We use the general solution to solve for the wave equation with the following initial conditions, and to plot the solution:

Clear[f,g]

f[x_] := 4 Cos[4 x]
g[x_] := x^2 - 1/3

u[1,f,g,t,x]

Although the formula for the solution is fairly simple, the wave forms it describes can be complicated.  For example, at unit time steps beginning at t=0, this solution looks as shown below.

First we add an optional step which allows Mathematica  to sketch the graphs more efficiently:

u[t_,x_] = %

Table[Plot[u[t,x], 
{x, -3, 3}], {t,0,4}]

We next consider how d'Alembert can incorporate boundary conditions

Model Problem VII.3.  As explained in the text, we extend the function f[x_] := x (1-x) from the interval  0 ≤ x ≤ 1 to the full range of x by reflecting in the odd manner about both end points:

Clear[f]

f[x_] := x (1 - x) /; 0 <= x <= 1
f[x_] := x (1 + x) /; -1 <= x < 0

Plot[f[x], {x,-1,1}]

f[x_] := - (2 - x) (1 - (2 - x)) /; 1 < x <= 2

Plot[f[x], {x,-1,2}]

This new territory can then be flipped over to the interval [-2,-1], etc:

f[x_] := x (1 - x) /; 0 <= x <= 1
f[x_] := x (1 + x) /; -1 <= x < 0
f[x_] := - (2 - x) (1 - (2 - x)) /; 1 < x <= 2
f[x_] := + (2 + x) (1 - (2 + x)) /; -2 <= x < -1
f[x_] := + (x - 2) (1 - (x - 2)) /; 2 < x <= 3

Plot[f[x], {x,-2,3}]

We could go on like this all day, or we could use modular arithmetic (the int and frac commands in programming languages, or, in Mathematica, Floor[x] and x - Floor[x] ) to automate it better, as follows.  Int and Frac give the integer and fractional parts of a number:

Int[x_] := Floor[x]
Frac[x_] := x - Floor[x]

{Int[3.89], Frac[3.89], Int[-3.89], Frac[-3.89]}

Notice that when we piece the function together, it is periodic with period 2.  Here is an alternative way to write the extended function f(x):

f[x_] := If[0 <= Frac[x/2] < 1/2, Frac[x] (1 - Frac[x]),               Frac[x] (Frac[x] - 1)]

Plot[f[x], {x,-2,3}]

Finally, we solve the IBVP:

g[x_] := 0

Table[Plot[u[1,f,g,t,x], 
{x, -1, 2}, PlotRange -> {-.3,.3}],{t,0,1.6,.2}]

It might be interesting to animate these pictures.  Notice that the wave does not simply jiggle up and down; its shape is changing, too.