Example 2 (Pulse 2)

Next consider a simple damped system y''+3y'+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[65]:=

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

Again, you will have to get comfortable with modeling using pulses and Heaviside functions!

In[66]:=

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

Here's the differential equation:

In[67]:=

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

Out[67]=

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

Here is the transformed differential equation:

In[68]:=

  tde=LaplaceTransform[de,t,s]

Out[68]=

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

Let's make use of the initial values:

In[69]:=

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

Out[69]=

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

Now solve this equation for Y[s].

In[70]:=

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

Out[70]=

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

In[71]:=

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

Out[71]=

                              2 - 2 t
  1     1       -t      1    E           1 - t
  - + ------ - E   + (-(-) - -------- + E     ) UnitStep[-1 + t]
  2      2 t            2       2
      2 E

In[72]:=

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

Remember, 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