Demonstration of how traveling waves form standing waves

Remove["Global`*"]

A standing wave, mathematically, is formed when two traveling waves moving in opposite directions “collide”. In order to demonstrate this fact, this notebook creates two finite-length wave trains and sets them into motion in opposite directions, initially heading towards each other. The two wave trains are otherwise identical to each other and during the period of time over which they overlap in space, it is clear that a standing wave is produced.

Form the traveling wave trains

trainR=Sin[Pi(x-v t)/2]UnitBox[(x-v t)/width];
trainL=Sin[Pi(x+v t)/2]UnitBox[(x+v t)/width];
trains=trainR+trainL;

Set some parameters

v=1;
end=35;
width=20;
tend=(end-0.6 width)/v;

Create the animation

anim=Animate[
Plot[ trains/.t->time,{x,-end,end},
PlotRange->{{-end,end},{-2,2}}],
{time,-tend,tend},
AnimationRunning->False,AnimationRate->2.0]

Do the following in order to export the animation to a file
Export[“CollidingWaves.mp4”,anim]
ExpandFileName[“CollidingWaves.mp4”]