Example 4 (Periodic Function)

Next consider a simple damped system y''+3y'+2y=f(t), y(0)=y'(0)=0 and its response to a periodic square wave 1 from 0 to Pi and -1 from Pi to 2Pi repeating with period 2Pi.

We cannot worry about infinite series, so instead we look at the solution over some interval, say 0 to 4Pi, so the input is a FINITE sum of square waves.


  Clear[f]
  f[t_]:=(UnitStep[t]-UnitStep[t-Pi])-(UnitStep[t-Pi]-UnitStep[t-2 Pi])+
  (UnitStep[t-2 Pi]-UnitStep[t-3 Pi])-(UnitStep[t-3 Pi]-UnitStep[t-4 Pi])
  Plot[Evaluate[f[t]],{t,0,4 Pi}];

The function is written in that way for your benefit. If you had a longer interval, you would need to be clever about it.


  Clear[g]
  g[t_]:=Sum[(-1)^k (UnitStep[t-k Pi]-UnitStep[t-(k+1) Pi]),{k,0,7}]
  Plot[Evaluate[g[t]],{t,0,8 Pi}];


  Clear[de,tde,newtde,Y,y]

Here's the differential equation:


  de=y''[t]+3 y'[t]+2 y[t]==f[t]

Here is the transformed differential equation:


  tde=LaplaceTransform[de,t,s]

Let's make use of the initial values:


  newtde=tde/.{y[0]->0,y'[0]->0}

Now solve this equation for Y[s].


  Solve[newtde,LaplaceTransform[y[t],t,s]];
  Y[s_]:=Evaluate[LaplaceTransform[y[t],t,s]/.Flatten[%]]
  Y[s]

Expect to wait for this one. Maybe go out for lunch.


  y[t_]:=InverseLaplaceTransform[Y[s],s,t]
  y[t]


  Plot[Evaluate[y[t]],{t,0,4 Pi}];

Up to Solving Constant Coefficient Initial Value Problems with Special Forcing Functions