d'Alembert's Solution to the Wave Equation

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

A string of length L is fixed at both ends with initial conditions u(x,0) = f(x) and diff(u(x,0),t) = g(x) . d'Alembert's solution to the wave equation is given by the expression u(x,t) below with fp(x) and gp(x) the odd periodic extensions of period 2L of f and g.

> u:=(x,t)->1/2*(fp(x+c*t)+fp(x-c*t))+1/(2*c)*int(gp(z),z=x-c*t..x+c*t);

u := proc (x, t) options operator, arrow; 1/2*fp(x+...

The odd extensions are obtained by first extending f and g to odd functions about %? . This gives one period of the extension.

> fodd:=x->piecewise(x<=L,f(x),x>L,-f(2*L-x)); godd:=x->piecewise(x<=L,g(x),x>L,-g(2*L-x));

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

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

Now, the functions are extended as periodic functions over the entire real line.

> fp:=x->fodd(Mod(x,2*L)); gp:=x->godd(Mod(x,2*L));

fp := proc (x) options operator, arrow; fodd(Mod(x,...

gp := proc (x) options operator, arrow; godd(Mod(x,...

Example 1: For a simple example, one finds that the above functions are defined correctly.

> L:=2: f:=x->x*(L-x); g:=0:

f := proc (x) options operator, arrow; x*(L-x) end ...

> plot({f(x),g(x)},x=0..L,color=[blue,red]);

[Maple Plot]

> plot({fodd(x),godd(x)},x=0..2*L,color=[blue,red]);

[Maple Plot]

> plot({fp(x),gp(x)},x=-2*L..3*L,color=[blue,red]);

[Maple Plot]

The solution to the wave equation can be animated. Click on the graph below and then on the play button [Maple Bitmap]

> c:=.2: animate( u(x,t),x=0..L,t=0..20,frames=50,color=blue);

[Maple Plot]

Here are other examples:

> L:=2:c:=.2: f:=x->piecewise(x<L/2,x*(L/2-x),x>L/2,0): g:=x->0:
animate( u(x,t),x=0..L,t=0..20,frames=50,color=blue);

[Maple Plot]

> L:=2:c:=.2:a:=L/4: f:=x->piecewise(x<=a,x/a,x>a,(L-x)/(L-a)): g:=x->0:
animate( u(x,t),x=0..L,t=0..20,frames=50,color=blue);

[Maple Plot]

> L:=2:c:=.2:a:=L/2: f:=x->sin(Pi*x/L): g:=x->0:
animate( u(x,t),x=0..L,t=0..20,frames=50,color=blue);

[Maple Plot]

> L:=2:c:=.2:a:=L/2: f:=x->sin(2*Pi*x/L): g:=x->0:
animate( u(x,t),x=0..L,t=0..20,frames=50,color=blue);

[Maple Plot]

> L:=2:c:=.2:a:=L/2: f:=x->sin(Pi*x/L)+.5*sin(2*Pi*x/L): g:=x->0:
animate( u(x,t),x=0..L,t=0..20,frames=50,color=blue);

[Maple Plot]

Try your own initial conditions and play with the wavespeed c.