Solutions for Standing Waves on a Fixed Length String

This notebook is used to teach the 27 Sept 2022 Wave Physics class

Remove["Global`*"]

Make things easy on ourselves, and set the wave amplitude, string length, and wave speed

A=3;
L=2;
v=1;

Calculate the period of the lowest fundamental mode

λ1=2L;
ν1=v/λ1;
T1=1/ν1;

Do our calculations for a fixed number of periods of the fundamental frequency

tMax=2T1;

First do a demo of numerically solving the differential equation. For this, we want a smooth function.

shape=10x^2(L-x)^2;
quart=shape A/(shape/.x->L/2);
Plot[quart,{x,0,L},PlotStyle->Black]

Note that this shape has a long wavelength in the middle, and what looks to be shorter wavelengths on the side. Therefore, we expect to see higher frequency components on the side than in the middle.

Now set up and (numerically) solve the wave equation with the appropriate boundary and initial conditions

waveEqn=(1/v^2)D[D[u[x,t],t],t]==D[D[u[x,t],x],x];

sol=NDSolve[
{waveEqn,
u[0,t]==0,u[L,t]==0,
u[x,0]==quart,Derivative[0,1][u][x,0]==0},
u[x,t],{x,0,L},{t,0,tMax}];

Plot the solution at three different times

wave=u[x,t]/.sol;
Plot[{wave/.t->0,wave/.t->0.5 T1,wave/.t->0.75 T1},{x,-0,L},
PlotStyle->{Black,Blue,Red}]

Notice that the solution looks a little ratty at the half-period time. This is a consequence of the limitations of numerical solutions, given the default parameters that I used.

Animate the solution, and watch the frequency in the middle and on the sides

Animate[
Plot[wave/.t->time,{x,0,L},PlotRange->{-1.05A,1.05A}],
{time,0,tMax},AnimationRunning->False]

Now let’s solve for the motion using Fourier analysis. First calculate the Fourier sine coefficients up to some maximum value of terms.

nMax=10;
nVals=Range[1,nMax];
AVals=(2/L)Integrate[quart Sin[nVals Pi x/L],{x,0,L}];

Plot the shape of the curve and compare to the Fourier decomposition

terms=AVals Sin[nVals Pi x/L];
u=Total[terms];
Plot[{quart,u},{x,0,L},PlotStyle->{Black,Red}]

Now add the time dependence

terms=AVals Sin[nVals Pi x/L]Cos[nVals Pi v t/L];
u=Total[terms];

Remake the plots at the same three times to check that all looks correct

Plot[{u/.t->0,u/.t->0.5 T1,u/.t->0.75 T1},{x,-0,L},
PlotStyle->{Black,Blue,Red}]

The rattiness is gone now. The half period shape is exactly the opposite of the initial shape because the cosine functions in the Fourier expansion all become “-1” at this time.

Now make the animation

Animate[
Plot[u/.t->time,{x,0,L},PlotRange->{-1.05A,1.05A}],
{time,0,tMax},AnimationRunning->False]

Now we can do any other functional shape using Fourier analysis. Start with the triangle wave.

shape=Piecewise[{{2x/L,x<L/2},{2(1-x/L),x>L/2}},{x,0,L}];
pluck=A shape;

f=pluck;
Plot[f,{x,0,L},PlotStyle->Black,PlotRange->{0,A}]

nMax=25;
nVals=Range[1,nMax];
AVals=(2/L)Integrate[f Sin[nVals Pi x/L],{x,0,L}];

terms=AVals Sin[nVals Pi x/L]Cos[nVals Pi v t/L];
u=Total[terms];

Animate[
Plot[u/.t->time,{x,0,L},PlotRange->{-1.05A,1.05A}],
{time,0,tMax},AnimationRunning->False]

Here are some other shapes. Pick one, and then to back and change “f” above and re-execute.

Lopsided pluck

lopside=A Piecewise[{{3x/(2L),x<2L/3},{3(1-x/L),x>2L/3}},{x,0,L}];

Narrow pluck

narrow=(A/L) Piecewise[
{{0,x<3L/8},
{8(x-3L/8),x>3L/8&&x<L/2},
{8(5L/8-x),x>L/2&&x<5L/8},
{0,x>5L/8}},{x,0,L}];

Square pluck

square=A Piecewise[{{0,x<L/3},{1,x>L/3&&x<2L/3},{0,x>2L/3}},{x,0,L}];

Quadratic pluck

quadratic=(4A/L^2)((L/2)^2-(x-L/2)^2);