d'Alembert's Solution to the Wave Equation

One end fixed and one end free

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

A string of length L is fixed at x = 0 and free at x = L 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 periodic extensions of period 4L of f and g odd at x = 0 and even at x = L .

> 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 extensions are obtained by first extending f and g for 0 < x < 4 L.. This gives one period of the extension.

> f1:=x->piecewise(x<=L,f(x),x<=2*L,f(2*L-x),x<=3*L,-f(4*L-x),x>3*L,-f(4*L-x)); g1:=x->piecewise(x<=L,g(x),x<=2*L,g(2*L-x),x<=3*L,-g(4*L-x),x>3*L,-g(4*L-x));

feven := proc (x) options operator, arrow; piecewis...

geven := proc (x) options operator, arrow; piecewis...

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

> fp:=x->f1(Mod(x,4*L)); gp:=x->g1(Mod(x,4*L));

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

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

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

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

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

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

[Maple Plot]

> plot({feven(x),geven(x)},x=0..4*L,color=[blue,red]);

[Maple Plot]

> plot({fp(x),gp(x)},x=-4*L..6*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..40,frames=50,color=blue);

[Maple Plot]

Here are other examples:

> L:=2:c:=.2:a:=L/2: f:=x->sin(Pi*x/L/2): 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(3*Pi*x/L/2): g:=x->0:
animate( u(x,t),x=0..L,t=0..40,frames=50,color=blue);

[Maple Plot]

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

[Maple Plot]

>

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