Example 1 (Pulse 1)

Consider a simple undamped system y''+2y=f(t), y(0)=y'(0)=0 and its response to a square wave f(t), where f(t)=1 between 0 and 1 and 0 otherwise.

In[57]:=

  f[t_]:=UnitStep[t]-UnitStep[t-1]
  Plot[f[t],{t,-2,3}];

You will have to get comfortable with modeling using pulses and Heaviside functions!

In[58]:=

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

Here's the differential equation:

In[59]:=

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

Out[59]=

  2 y[t] + y''[t] == -UnitStep[-1 + t] + UnitStep[t]

Here is the transformed differential equation:

In[60]:=

  tde=LaplaceTransform[de,t,s]

Out[60]=

                                    2
  2 LaplaceTransform[y[t], t, s] + s  LaplaceTransform[y[t], t, s] - 
   
                       1    1
     s y[0] - y'[0] == - - ----
                       s    s
                           E  s

Let's make use of the initial values:

In[61]:=

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

Out[61]=

                                    2
  2 LaplaceTransform[y[t], t, s] + s  LaplaceTransform[y[t], t, s] == 
   
    1    1
    - - ----
    s    s
        E  s

Now solve this equation for Y[s].

In[62]:=

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

Out[62]=

            s
       1 - E
  -(-------------)
     s         2
    E  s (2 + s )

In[63]:=

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

Out[63]=

  1   Cos[Sqrt[2] t]      1    Cos[Sqrt[2] (-1 + t)]
  - - -------------- + (-(-) + ---------------------) UnitStep[-1 + t]
  2         2             2              2

In[64]:=

  Plot[Evaluate[y[t]],{t,0,6}];

The Evaluate[ ] command is to allow Mathematica to do a complicated plot more quickly.

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