Example 1

Let's solve the initial value problem y'+4y=t, y(0)=5. The procedure is just like we did by hand, but with Mathematica relieving us of the tedium.

In[43]:=

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

Here's the differential equation:

In[44]:=

  de=y'[t]+4 y[t]==t

Out[44]=

  4 y[t] + y'[t] == t

Here is the transformed differential equation:

In[45]:=

  tde=LaplaceTransform[de,t,s]

Out[45]=

  4 LaplaceTransform[y[t], t, s] + s LaplaceTransform[y[t], t, s] - 
   
              -2
     y[0] == s

Let's make use of the initial value:

In[46]:=

  newtde=tde/.y[0]->5

Out[46]=

  -5 + 4 LaplaceTransform[y[t], t, s] + 
   
                                        -2
     s LaplaceTransform[y[t], t, s] == s

Now solve this equation for Y[s], which Mathematica calls
LaplaceTransform[y[t],t,s]. The extra commands are to make the solution be a function, not a list of rules.

In[47]:=

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

Out[47]=

            2
    -1 - 5 s
  -(----------)
     2
    s  (4 + s)

Now transform back to find y(t).

In[48]:=

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

Out[48]=

    1       81      t
  -(--) + ------- + -
    16        4 t   4
          16 E

Check:

In[49]:=

  Simplify[D[y[t],t]+4 y[t]]

Out[49]=

  t

Up to Solving Constant Coefficient Differential Equations (Initial Value Problems)