Worksheet: d'Alembert.mw 

d'Alembert Solution and Fourier Sine Series Solutions to the Wave Equation 

 

This worksheet examines the sine series that arises in a separation of variables  

solution for the wave equation : 

 

u[tt]=`*`(`^`(c, 2))u[xx]     0 < x < L     u(0,t)=u(L,t)=0 

with initial condition 

u(x,0)=F(x)=L/2-abs(x-L/2)       0 < x< L 

u[t](x,0)=G(x)=0                               0 < x< L 

> restart:with(plots):
 

> L:=1;c:=1;
 

 

1
1 (1)
 

Least Squares Approximation of The Initial Condition 

Let's approximate the initial condition F(x) with the sum of sines that came from separation of variables. 

> F:=x->L/2-abs(x-L/2);
 

proc (x) options operator, arrow; `+`(`*`(`/`(1, 2), `*`(L)), `-`(abs(`+`(x, `-`(`*`(`/`(1, 2), `*`(L))))))) end proc (1.1)
 

> plot(F(x), x=0..L);
 

Plot_2d
 

> f:=n-> sin (n*Pi*x/L);
 

proc (n) options operator, arrow; sin(`/`(`*`(n, `*`(Pi, `*`(x))), `*`(L))) end proc (1.2)
 

> a:=n->(2/L)*int(F(x)*f(n),x=0..L);
 

proc (n) options operator, arrow; `+`(`/`(`*`(2, `*`(int(`*`(F(x), `*`(f(n))), x = 0 .. L))), `*`(L))) end proc (1.3)
 

> seq(a[n]=a(n),n=1..10);
 

a[1] = `+`(`/`(`*`(4), `*`(`^`(Pi, 2)))), a[2] = 0, a[3] = `+`(`-`(`/`(`*`(`/`(4, 9)), `*`(`^`(Pi, 2))))), a[4] = 0, a[5] = `+`(`/`(`*`(`/`(4, 25)), `*`(`^`(Pi, 2)))), a[6] = 0, a[7] = `+`(`-`(`/`(`*`... (1.4)
 

> g:= M->sum(a(m)*f(m),m=1..M);
 

proc (M) options operator, arrow; sum(`*`(a(m), `*`(f(m))), m = 1 .. M) end proc (1.5)
 

> h:=g(3);
 

`+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))))), `*`(`^`(Pi, 2))), `-`(`/`(`*`(`/`(4, 9), `*`(sin(`+`(`*`(3, `*`(Pi, `*`(x))))))), `*`(`^`(Pi, 2))))) (1.6)
 

> plot({F(x),h},x=0..L);
 

Plot_2d
 

> s:=seq(g(2*M-1),M=1..6);
 

`+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))))), `*`(`^`(Pi, 2)))), `+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))))), `*`(`^`(Pi, 2))), `-`(`/`(`*`(`/`(4, 9), `*`(sin(`+`(`*`(3, `*`(Pi, `*`(x))))))), `*`(`^`(Pi, 2...
`+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))))), `*`(`^`(Pi, 2)))), `+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))))), `*`(`^`(Pi, 2))), `-`(`/`(`*`(`/`(4, 9), `*`(sin(`+`(`*`(3, `*`(Pi, `*`(x))))))), `*`(`^`(Pi, 2...
`+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))))), `*`(`^`(Pi, 2)))), `+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))))), `*`(`^`(Pi, 2))), `-`(`/`(`*`(`/`(4, 9), `*`(sin(`+`(`*`(3, `*`(Pi, `*`(x))))))), `*`(`^`(Pi, 2...
`+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))))), `*`(`^`(Pi, 2)))), `+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))))), `*`(`^`(Pi, 2))), `-`(`/`(`*`(`/`(4, 9), `*`(sin(`+`(`*`(3, `*`(Pi, `*`(x))))))), `*`(`^`(Pi, 2...
(1.7)
 

> plot({s,F(x)},x=0..L);
 

Plot_2d
 

Wave Equation via Fourier Sine Series 

We can now reconstitute our solution to the heat equation, with the initial condition we derived. 

> u:=M->sum(a(m)*sin(m*Pi*x/L)*cos(c*m*Pi*t/L),m=1..M);
 

proc (M) options operator, arrow; sum(`*`(a(m), `*`(sin(`/`(`*`(m, `*`(Pi, `*`(x))), `*`(L))), `*`(cos(`/`(`*`(c, `*`(m, `*`(Pi, `*`(t)))), `*`(L)))))), m = 1 .. M) end proc (2.1)
 

> up:=u(10);
 

`+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))), `*`(cos(`*`(Pi, `*`(t)))))), `*`(`^`(Pi, 2))), `-`(`/`(`*`(`/`(4, 9), `*`(sin(`+`(`*`(3, `*`(Pi, `*`(x))))), `*`(cos(`+`(`*`(3, `*`(Pi, `*`(t)))))))), `*`(`^`(...
`+`(`/`(`*`(4, `*`(sin(`*`(Pi, `*`(x))), `*`(cos(`*`(Pi, `*`(t)))))), `*`(`^`(Pi, 2))), `-`(`/`(`*`(`/`(4, 9), `*`(sin(`+`(`*`(3, `*`(Pi, `*`(x))))), `*`(cos(`+`(`*`(3, `*`(Pi, `*`(t)))))))), `*`(`^`(...
(2.2)
 

> plot3d(up,x=0..L,t=0..2.0,style=patchcontour,shading=zhue,axes=boxed);
 

Plot_2d
 

> animate(up,x=0..L,t=0..2*L,frames=51);
 

Plot_2d
 

d'Alembert Solution 

We can construct a d'Alembert solution for the same initial condition by constructing the odd  

periodic extension of the initial condition F(x) 

> p:=x->x-2*L*floor((x-L)/(2*L))-2*L;
 

proc (x) options operator, arrow; `+`(x, `-`(`*`(2, `*`(L, `*`(floor(`+`(`/`(`*`(`/`(1, 2), `*`(`+`(x, `-`(L)))), `*`(L)))))))), `-`(`*`(2, `*`(L)))) end proc (3.1)
 

> plot(p(x),x=-3*L..3*L);
 

Plot_2d
 

> F1:=x->signum(x)*F(abs(x));
 

proc (x) options operator, arrow; `*`(signum(x), `*`(F(abs(x)))) end proc (3.2)
 

> plot(F1(x),x=-L..L);
 

Plot_2d
 

> F2:=x->F1(p(x));
 

proc (x) options operator, arrow; F1(p(x)) end proc (3.3)
 

> plot(F2(x),x=-3*L..3*L);
 

Plot_2d
 

> U:=(F2(x-c*t)+F2(x+c*t))/2:
 

> plot3d(U,x=0..L,t=0..2.0,style=patchcontour,shading=zhue,axes=boxed);
 

Plot_2d
 

> animate(U,x=0..L,t=0..2*L,frames=51);
 

Plot_2d
 

> animate({U,-up},x=0..L,t=0..2*L,frames=51,thickness=3);
 

Plot_2d
 

>