Example 6.5.5

Clear[y]

Let's have Mathematica solve it so we have something to compare to:

L[y_]:=D[y,{t,2}]+2D[y,{t,1}]+3y==Sin[t]-DiracDelta[t-3Pi]

L[y[t]]

DSolve[{L[y[t]],y[0]==0,y'[0]==0},y[t],t]

realsolplot=Plot[-(1/4) (E^(-t)) (-Cos[(Sqrt[2]) t]+(E^t) Cos[t] ((Cos[(Sqrt[2]) t])^2)-2 (Sqrt[2]) (E^(3 π)) Cos[(Sqrt[2]) t] HeavisideTheta[-3 π+t] Sin[3 (Sqrt[2]) π]-(E^t) ((Cos[(Sqrt[2]) t])^2) Sin[t]+2 (Sqrt[2]) (E^(3 π)) Cos[3 (Sqrt[2]) π] HeavisideTheta[-3 π+t] Sin[(Sqrt[2]) t]+(E^t) Cos[t] ((Sin[(Sqrt[2]) t])^2)-(E^t) Sin[t] ((Sin[(Sqrt[2]) t])^2)),{t,0,20},PlotStyle->{Red,Thick}]

We can use this (mainly the plot) as a check if we like.

Here is the partial fraction expansion we need:

Apart[1/(s^2+1)/(s^2+2s+3)]

Let's check if we got the solution right

ysol[t_]=-1/4Cos[t]+1/4Sin[t]+1/4 Exp[-t]Cos[Sqrt[2]t]-1/Sqrt[2]HeavisideTheta[t-3Pi]Exp[-t+3Pi]Sin[Sqrt[2]t-3Sqrt[2]Pi]

Simplify[L[ysol[t]]]

It could be correct, but Mathematica couldn't simplify to True. Let's just show the graphs are the same.

solplot =Plot[ysol[t],{t,0,20},PlotStyle->Thick]

Show[solplot,realsolplot]

Example 6.5.14

Clear[y]

Let's have Mathematica solve it so we have something to compare to:

L[y_]:=D[y,{t,2}]+γ D[y,{t,1}]+y==DiracDelta[t-1]

L[y[t]]

DSolve[{L[y[t]],y[0]==0,y'[0]==0},y[t],t]

Simplify[%]

Manipulate[Plot[-(((E^((1/2) (γ-t γ-(1+t) (Sqrt[-4+(γ^2)])))) ((E^(Sqrt[-4+(γ^2)]))-(E^(t (Sqrt[-4+(γ^2)])))) HeavisideTheta[-1+t])/(Sqrt[-4+(γ^2)])),{t,0,10},PlotStyle->{Red,Thick},PlotRange->{{0,10},{-1,1}}],{γ,0,3,1/4}]

Notice the Mathematica solution does not work for γ=2.

Let's check if we got the solution right

Clear[ysol,γ]

ysol[t_,γ_]:=Piecewise[{{(1/(Sqrt[1-(γ^2)/4]))Heaviside[t-1]Exp[-γ(t-1)/2]Sin[(Sqrt[1-(γ^2)/4])(t-1)],γ≠2},{Exp[1-t] (t-1) Heaviside[t-1],γ==2}}]

ysol[t,2]

Let's just show the graphs are the same.

Clear[γ]
Manipulate[Plot[ysol[t,k],{t,0,10},PlotStyle->{Blue,Thick},PlotRange->{{0,10},{-1,1}}],{k,0,3,1/4}]