Initialization

SetOptions[Plot,PlotStyle->{Black,AbsoluteThickness[2]},
ImageSize->500,AxesStyle->Directive[FontFamily->"Arial",FontSize->18,Black,AbsoluteThickness[0.5],Arrowheads[0.04]]];

Initial Conditions
Oregon State University, Department of Physics 2006-09
Janet Tate

The general form of the solution to the wave equation is restricted by imposition of initial conditions (the waveform and velocity at a particular time).  Starting with a general solution of the form

Acos(kx)cos(ωt) + Bcos(kx)sin(ωt) + Fsin(kx)cos(ωt) + Gsin(kx)sin(ωt)
(in class we use C for F and D for G, but these are protected in Mathematica)
put in particular values for the coefficients (particular initial conditions) and see what waveforms result.

Start with a general waveform that is a superposition of standing waves.

Clear[A,B,F,G]

ψ[x_,t_]:=A*Cos[k*x]*Cos[ω*t]+ B*Cos[k*x]*Sin[ω*t]+F*Sin[k*x]*Cos[ω*t]+G*Sin[k*x]*Sin[ω*t]

Set the wavelength equal to 1 unit and period equal to 1 unit, for easy plotting:

k=2*Pi/1
ω=2*Pi/1

Now set values for the coefficients:

A=1
B=0
F=0
G=1

Animate[Plot[ψ[x,t],{x,-2,2},AxesLabel->{x,ψ},PlotStyle->{Blue, AbsoluteThickness[2]},PlotLabel->t,PlotRange->{{-2,2},{-1.5,1.5}}],{t,0,2}, AnimationRunning->False]

Here are several sets of coefficients.  Execute a set, then execute the Animation function again.  It will run with the the most recent set of coefficients.

A=0
B=0
F=1
G=0

A=0
B=1
F=1
G=0

A=1
B=0
F=0
G=1

A=0
B=0
F=1
G=1