Motivating a trig identity

Plot[5Cos[θ]-12Sin[θ],{θ,-2Pi,2Pi}]

Manipulate[Plot[A Cos[θ]+B Sin[θ],{θ,-2Pi,2Pi},PlotRange->{-20,20}],{A,-10,10},{B,-10,10}]

Normal modes

u[x_,t_,n_,l_,c_]=Cos[n Pi/l c t]Sin[n Pi/l x]

Animate[Plot[u[x,t,1,1,1],{x,0,1},PlotRange->{-1,1}],{t,0,2},AnimationRunning->False]

Animate[Plot[u[x,t,2,1,1],{x,0,1},PlotRange->{-1,1}],{t,0,2},AnimationRunning->False]

Animate[
GraphicsRow[Table[Plot[u[x,t,n,1,1],{x,0,1},PlotRange->{-1,1}],{n,1,3}],ImageSize->Large],
{t,0,2},
AnimationRunning->False]

Animate[Plot[u[x,t,1,1,1]+u[x,t,2,1,1]+u[x,t,3,1,1],{x,0,1},PlotRange->{-3,3}],{t,0,2},AnimationRunning->False]

Play[Cos[440*2Pi t],{t,0,2}]

D'Alembert solution for wave equation on a bounded interval

Define an initial displacement on the interval (0,1):

f[x_]=Piecewise[{{x/10,0<=x<=0.5},{(1-x)/10,0.5<=x<=1}}]

Plot[f[x],{x,-2,2},PlotRange->All]

Build the odd extension to the interval (-1,1):

fodd[x_]=Piecewise[{{-f[-x],-1<=x<=0},{f[x],0<=x<=1}}]

Plot[fodd[x],{x,-2,2},PlotRange->All]

Use modular arithmetic to build the odd extension to all x:

foddext[x_]:=fodd[1-Mod[x,2]]

Plot[foddext[x],{x,-9,9},PlotRange->All,PlotPoints->1000]

Look at a left-translation (green), and right-translation (red), and the sum (blue):

Plot[{foddext[x-0.2]/2,foddext[x+0.2]/2,(foddext[x-0.2]+foddext[x+0.2])/2},{x,-2,2},PlotStyle->{{Thick,Red,Opacity[1]},{Thick,Green,Opacity[1]},{Thick,Blue}},
PlotPoints->150]

Animate this:

Animate[Plot[{foddext[x-t]/2,foddext[x+t]/2,(foddext[x-t]+foddext[x+t])/2},{x,-2,2},
PlotRange->{-0.05,0.05},
PlotStyle->{{Thick,Red,Opacity[1]},{Thick,Green,Opacity[1]},{Thick,Blue}}],
{t,0,2},
AnimationRunning->False]

Animate with viewing window restricted to the relevant domain:

Animate[Plot[{foddext[x-t]/2,foddext[x+t]/2,(foddext[x-t]+foddext[x+t])/2},{x,0,1},
PlotRange->{-0.06,0.06},PlotStyle->{{Thick,Red,Opacity[0.35]},{Thick,Green,Opacity[0.35]},{Thick,Blue}}],{t,0,2},AnimationRunning->False]

Build frames for exporting to an animated GIF:

myframes=Table[Plot[{foddext[x-t]/2,foddext[x+t]/2,(foddext[x-t]+foddext[x+t])/2},{x,0,1},
PlotRange->{-0.06,0.06},PlotStyle->{{Thick,Red,Opacity[0.35]},{Thick,Green,Opacity[0.35]},{Thick,Blue}},
Ticks->{{0,{1,"L"}},None}],{t,0,2,0.05}];

Export["wavesoln.gif",myframes]

This animated GIF is the one on the course web page.