Example 6.4.3

Clear[y]

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

L[y_]:=D[y,{t,2}]+4y==Sin[t]-HeavisideTheta[t-2Pi]Sin[t-2Pi]

L[y[t]]

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

We can use this as a check if we like.

Here is the partial fractions:

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

Let's check if we got the solution right

ysol[t_]=Sin[t]/3-Sin[2t]/6 - HeavisideTheta[t-2Pi]Sin[t]/3+ HeavisideTheta[t-2Pi]Sin[2t]/6

Simplify[L[ysol[t]]]

Excellent.

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

forcingplot =Plot[Sin[t]-HeavisideTheta[t-2Pi]Sin[t-2Pi],{t,0,10},PlotStyle->Thick]

The forcing function turns off after t=2π. Since the initial conditions are both zero, if we were to think of this as a mechanical vibration problem the particle is initially at the origin with no velocity--the forcing function is what makes the particle move. In this case, the forcing function is such that it takes the particle through one oscillation, and deposits it back at the origin with velocity zero and then it turns off at t=2π, leaving the particle there for greater times.

Example 6.4.11

Clear[y]

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

L[y_]:=D[y,{t,2}]+4y==HeavisideTheta[t-Pi]- HeavisideTheta[t-3Pi]

L[y[t]]

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

We can use this as a check if we like.

Here is the partial fractions:

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

Let's check if we got the solution right

ysol[t_]= HeavisideTheta[t-Pi]/4- HeavisideTheta[t-Pi]Cos[2t]/4-HeavisideTheta[t-3Pi]/4+ HeavisideTheta[t-3Pi]Cos[2t]/4

Simplify[L[ysol[t]]]

Excellent.

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

forcingplot =Plot[HeavisideTheta[t-Pi]- HeavisideTheta[t-3Pi],{t,0,10},PlotStyle->Thick]

The forcing function turns on between t=π and t=3π. Since the initial conditions are both zero, if we were to think of this as a mechanical vibration problem the particle is initially at the origin with no velocity--the forcing function is what makes the particle move. In this case, the forcing function is such that it takes the particle through two oscillations, and deposits it back at the origin with velocity zero and then it turns off at t=3π, leaving the particle there for greater times.

Example 6.4.11 with different forcing function

Based on the previous two examples, you might think that the solution will always be zero unless the forcing function is acting. Let's investigate.

Clear[y]

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

L[y_]:=D[y,{t,2}]+4y==HeavisideTheta[t-Pi]- HeavisideTheta[t-2Pi/3]

L[y[t]]

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

Let's check if we got the solution right

ysol[t_]=(1/8) (-3 Cos[2 t]-(Sqrt[3]) Sin[2 t])+((1/8) (-2-Cos[2 t]-(Sqrt[3]) Sin[2 t])+(1/8) (3 Cos[2 t]+(Sqrt[3]) Sin[2 t])+(1/8) (2+Cos[2 t]+(Sqrt[3]) Sin[2 t]) UnitStep[((2 π)/3)-t]) UnitStep[π-t]

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

forcingplot =Plot[HeavisideTheta[t-Pi]- HeavisideTheta[t-2Pi/3],{t,0,10},PlotStyle->Thick]

The forcing function turns on between t=π and t=2π/3. Since the initial conditions are both zero, if we were to think of this as a mechanical vibration problem the particle is initially at the origin with no velocity--the forcing function is what makes the particle move. We see that in the plot of the solution. In this case, when the forcing function turns off, the particle is not at the origin and has some nonzero velocity. This means the particle continues to oscillate after the forcing function has turned off. Since there is no damping, the oscillation continues forever.

Example 6.4.19

Based on the previous two examples, you might think that the solution will always be zero unless the forcing function is acting. Let's investigate.

Clear[y]

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

L[y_]:=D[y,{t,2}]+y==HeavisideTheta[t]+2(∑_(k=1)^n)(((-1))^k)HeavisideTheta[t-k*Pi]

L[y[t]]

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

Let's check if we got the solution right

ysol[t_]=(1/8) (-3 Cos[2 t]-(Sqrt[3]) Sin[2 t])+((1/8) (-2-Cos[2 t]-(Sqrt[3]) Sin[2 t])+(1/8) (3 Cos[2 t]+(Sqrt[3]) Sin[2 t])+(1/8) (2+Cos[2 t]+(Sqrt[3]) Sin[2 t]) UnitStep[((2 π)/3)-t]) UnitStep[π-t]

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

Manipulate[Plot[HeavisideTheta[t]+2(∑_(k=1)^n)(((-1))^k)HeavisideTheta[t-k*Pi],{t,0,50},PlotRange->{{0,50},{-1,1}},PlotStyle->Thick],{n,0,15,1}]

Manipulate[Plot[HeavisideTheta[t]+(∑_(k=1)^n)((((-1))^k)/k)HeavisideTheta[t-k*Pi],{t,0,50},PlotRange->{{0,50},{-1,1}},PlotStyle->Thick],{n,0,15,1}]