MATH528 Lesson07
Inhomogeneous, constant coefficient, second-order ODEs

General solution

rhs=m y''[t]+c y'[t]+k y[t];r[t_]=F Cos[omega t];
hODE=rhs==0;
hsol[t_,m_,c_,k_]=y[t]/.DSolve[hODE,y[t],t][[1,1]]

Particular solution

psol[t_]=a Cos[omega t]+b Sin[omega t]

uCoef = Simplify[Evaluate[rhs /. y->psol] - r[t]]

sys={Coefficient[uCoef,Cos[omega t],1],Coefficient[uCoef,Sin[omega t],1]}=={0,0}

yp[t_,m_,c_,k_,omega_]=psol[t]/.Solve[sys,{a,b}][[1]]

y[t_,m_,c_,k_,omega_]=hsol[t,m,c,k]+yp[t,m,c,k,omega]

yd[t_,m_,c_,k_,omega_]=D[y[t,m,c,k,omega],t]

sol[t_,m_,c_,k_,omega_]=Simplify[ y[t,m,c,k,omega] /. Solve[{y[0,m,c,k,omega],yd[0,m,c,k,omega]} == {y0,v0},{C[1],C[2]}][[1]]]

Interactive investigation of solution

Manipulate[Plot[Evaluate[sol[t,m,c,k,omega] /. {y0->y0v,v0->v0v,F->Fv}],{t,0,20},PlotRange->{{0,10},{-5,5}},Axes->False,Frame->True,GridLines->Automatic, FrameLabel->{"t","y(t)"},PlotLabel->"(Subscript[ω, 0])=" <>ToString[ (Sqrt[k/m])]],{{m,1},0.1,10},{c,0,1},{k,1,10},{omega,0,10},{{y0v,0},-1,1},{{v0v,0},-1,1},{{Fv,1},-2,2}]