d'Alembert's Solution for g(x) = 0

A string of length L is fixed at both ends with initial conditions u(x,0) = f(x) and diff(u(x,0),x) = g(x) . d'Alembert's solution to the wave equation is given by u(x,t) = F(x+ct)+G(x-ct) , where F(x) and G(x) are determined from the odd extensions of f(x) and g(x) about both x = 0 and x = L .

In this example, we will consider an initial profile with zero initial velocity. We will see how one puts together the odd extensions to form an odd periodic extension of
f(x) with period 2*L . This periodic function can then be used to produce the desired solution of the wave equation.

> restart: with(plots): Mod:=(x,y)->x-floor(x/y)*y:

Warning, the name changecoords has been redefined

Let f(x) be the function defined on [0,L]. We first extend it to f1(x) , which is defined on [0,2L] and is odd about x = L .

> f:=x->piecewise(x<=a,x/a,x<=L,(L-x)/(L-a));
f1:=x->piecewise(x<=L,f(x),x<=2*L,-f(2*L-x));

f := proc (x) options operator, arrow; piecewise(x ...

f1 := proc (x) options operator, arrow; piecewise(x...

> a:=L/4: L:=1: plot(f(x),x=0..L,title=`Initial Profile u(x,0)`);

[Maple Plot]

> plot(f1(x),x=0..2*L,title=`Extension to [0,2L]`);

[Maple Plot]

Now we fully extend f(x) to the entire real line as a periodic function of period 2*L . From d'Alembert's solution with g(x) = 0 , we can write down F(x), G(x) and the solution u(x,t) . First we obtain F and G (which are the same in this example) :

> F:=x->1/2*f1(Mod(x,2*L)); G:=x->-F(-x);

F := proc (x) options operator, arrow; 1/2*f1(Mod(x...

G := proc (x) options operator, arrow; -F(-x) end p...

We plot F and u(x,0) = F(x)+G(x) , which is the "taller" of the two functions.

> plot({F(x), F(x)+G(x)},x=-4*L..4*L,color=[blue,red]);

[Maple Plot]

As t increases, we can look at the sum of the left and right traveling waves for a unit speed. In the plot below u has been vertically shifted for visualization purposes.

> t:=0.6:
plot({F(x+t), G(x-t),F(x+t)+G(x-t)+1,1},x=-4*L..4*L,color=[blue,red, green]);

[Maple Plot]

Animation of the above functions over one period of time. Try to visualize the right and left traveling waves in the lower portion of the plot.

> t:='t': animate({F(x+t), G(x-t),F(x+t)+G(x-t)+1,1},x=-4*L..4*L,t=0..4, numpoints=100,frames=50,color=blue);

[Maple Plot]

Animation of the solution over the physical interval [0,L].

> t:='t': animate(F(x+t)+G(x-t),x=0..L,t=0..4, numpoints=200,frames=100,color=blue,title=`u(x,t)`);

[Maple Plot]

>

>