Simple Harmonic Motion

Author

Eric W. Weisstein
May 3, 2004

This notebook downloaded from http://mathworld.wolfram.com/notebooks/DifferentialEquations/SimpleHarmonicMotion.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/SimpleHarmonicMotion.html.

©2005 Wolfram Research, Inc. except for portions noted otherwise

Code

SHO[{beta_,w_,t_},C_List:{1,0}]:=Module[{D=beta^2-4w^2,r1,r2,gamma},Which[D>0,r1=(-beta+Sqrt[beta^2-4 w^2])/2;
r2=(-beta-Sqrt[beta^2-4 w^2])/2;
C[[1]] Exp[r2 t]+C[[2]] Exp[r1 t],D<0,gamma=Sqrt[4 w^2-beta^2]/2;
Exp[-beta t/2](C[[1]] Cos[gamma t]+C[[2]] Sin[gamma t]),D==0,(C[[1]]+C[[2]]t)Exp[-w t]]]

SHOType[{beta_,w_,t_},C_List:{1,0},periods_:2]:=Module[{D=beta^2-4w^2,r1,r2,gamma},Which[D>0,Print["Overdamped, D=",D,">0"],D<0,Print["Underdamped, D=",D,"<0"],D==0,Print["Critically damped, D=",D];
];
Print[SHO[{beta,w,t}]];
]

SHOForced[{beta_,w_,w0_,t_},A_:1]:=Module[{D=beta^2-4w^2,r1,r2,gamma,delta},Which[D>0,delta=ArcTan[beta w/(w^2-w0^2)];
A/Sqrt[(w^2-w0^2)^2+beta^2 w^2] Cos[w t+delta],D<0,delta=ArcTan[beta w/(w^2-w0^2)];
A Sqrt[(w0^2-w^2)^2+beta^2 w^2]/((w0^2-w^2)^2-w^2(4w0^2-beta^2)) Cos[w t+delta],D==0,delta=ArcTan[2 w w0/(w^2-w0^2)];
A/(w^2+w0^2)Cos[w t+delta]]]