Illustrations of Harmonic Motion for 14 Feb 2023

Remove["Global`*"]

Figure 3.2

Underdamping case

ampFact= R Exp[-β t];
x=ampFact Cos[ω1 t+ϕ];

sol=Solve[{(x/.t->0)==x0,(D[x,t]/.t->0)==v0},{R,ϕ}];

Rsol=Normal[Simplify[(R/.sol)]][[2]];
ϕsol=Normal[Simplify[(ϕ/.sol)]][[2]]/.(C[1])->0;

ω0Val=2Pi;
βVal=0.05 ω0Val;
ω1Val=Sqrt[ω0Val^2-βVal^2];
xPlot=(x/.{R->Rsol,ϕ->ϕsol})/.{ω1->ω1Val,β->βVal};

xPlot1=xPlot/.{x0->10,v0->0};
xPlot2=xPlot/.{x0->0,v0->5 ω0Val};
ampPlot=ampFact/.R->Rsol/.{ω1->ω1Val,β->βVal}/.{x0->10,v0->0};

Plot[{xPlot1,xPlot2,ampPlot},{t,0,8},
PlotRange->{-11,11},
LabelStyle->{Black,15},
PlotStyle->{
{Thick,Black,Solid},
{Thick,Black,Dashed},
{Thick, Black,Dotted}},
PlotLegends->{"v0=0","x0=0"}]

Figure 3.3 (Left)

Overdamping case

α1=-β+Sqrt[β^2-ω0^2];
α2=-β-Sqrt[β^2-ω0^2];
x=c1 Exp[α1 t]+c2 Exp[α2 t];

sol=Solve[{(x/.t->0)==x0,(D[x,t]/.t->0)==v0},{c1,c2}];

βVal=1.25 ω0Val;

xPlot1=x/.sol/.{ω0->ω0Val,β->βVal}/.{x0->10,v0->0};
xPlot2=x/.sol/.{ω0->ω0Val,β->βVal}/.{x0->0,v0->5 ω0Val};

Plot[{xPlot1,xPlot2},{t,0,1.5},
PlotRange->{0,11},
LabelStyle->{Black,15},
PlotStyle->{
{Thick,Black,Solid},
{Thick,Black,Dashed}},
PlotLegends->Placed[{"v0=0","x0=0"},Center]]

Figure 3.3 (Right)

Critical damping case

α=-β;
x=(c1 +c2 t)Exp[α t];

sol=Solve[{(x/.t->0)==x0,(D[x,t]/.t->0)==v0},{c1,c2}];

xPlot1=x/.sol/.{ω0->ω0Val,β->βVal}/.{x0->10,v0->0};
xPlot2=x/.sol/.{ω0->ω0Val,β->βVal}/.{x0->0,v0->5 ω0Val};

Plot[{xPlot1,xPlot2},{t,0,1.5},
PlotRange->{0,11},
LabelStyle->{Black,15},
PlotStyle->{
{Thick,Black,Solid},
{Thick,Black,Dashed}},
PlotLegends->Placed[{"v0=0","x0=0"},Center]]

Figure 3.6

Plot the amplitude and phase of particular solution as a function of driving frequency

γVal=10;
ω0Val=2Pi;
βVal=0.05 ω0Val;

A=γ/Sqrt[4β^2ω^2+(ω0^2-ω^2)^2];
Φ=ArcTan[ω0^2-ω^2,2β ω];

Aplot=A/.{γ->γVal,ω0->ω0Val,β->βVal};
Φplot=Φ/.{γ->γVal,ω0->ω0Val,β->βVal};

Plot[{Aplot,Φplot},{ω,0,2ω0Val},
LabelStyle->{Black,15},
PlotStyle->{{Thick,Black,Solid},{Thick,Black,Dashed}},
PlotLegends->{"Amplitude","Phase"},
AxesLabel->{"ω",""}]

Interactive version of Fig. 3.5

Use Manipulate to change the driving frequency

ampFact= R Exp[-β t];
x=ampFact Cos[ω1 t+ϕ]+A Cos[ω t-Φ];

Solve for R and ϕ for initial conditions x(0)=0 and v(0)=0

sol=Solve[{(x/.t->0)==0,(D[x,t]/.t->0)==0},{R,ϕ}];
Rsol=Normal[Simplify[(R/.sol)]][[2]];
ϕsol=Normal[Simplify[(ϕ/.sol)]][[2]]/.(C[1])->0;

xPlot=(x/.{R->Rsol,ϕ->ϕsol})/.{ω0->ω0Val,ω1->ω1Val,β->βVal,γ->γVal};

N[ω0Val]

Manipulate[
Plot[xPlot/.ω->ω0Set,{t,0,12},
PlotRange->{-2.5,2.5},
LabelStyle->{Black,15},
PlotStyle->{Thick,Black}],
{ω0Set,0.1ω0Val,2ω0Val}]