# Asmar 3.4-15, D'Alembert's solution of the wave equation, f=pulses,g=0 pulse:=(x,a,b)->piecewise(x4*x*pulse(x,0,1/4)+(2-4*x)*pulse(x,1/4,1/2); #plot(f(x),x=0..1); F0:=x->piecewise(x<0,-f(-x),f(x));F:=x->F0(x-2*floor((x+1)/2)); plot(F(x),x=-1..4); u:=(x,t)->(1/2)*(F(x+t)+F(x-t)); #plot(u(x,0.7),x=-2..2); with(plots): animate( plot, [u(x,t),x=-3..3], t=0..1.5, trace=0, frames=50 );