MATH 302-010
Ordinary Differential Equations
Prof. D. A. Edwards
Copyright 2024

Laplace Transforms and ODEs

We begin with our standard command:

Quit[]

Laplace Transforms for ODEs

Though it is far easier to use DSolve, we can certainly solve ODEs using Laplace transforms in Mathematica.  Consider the following equation:

eq3 = f''[t]+3*f'[t]+f[t]==0

We can Laplace transform the whole equation:

leq3=LaplaceTransform[eq3,t,s]

Of course, the Laplace transform requires the initial conditions, which we write as equations for future reference, though we have to substitute using arrows:

ic3a=f[0]==3
ic3b=f'[0]==1
leq3a = leq3/.{f[0]->3,f'[0]->1}

Next we must solve for the transform, which in Mathematica is given by (Subscript[ℒ, t])[f(t)](s).  (Often the easiest thing is to copy and paste from the output line.)

Solve[leq3a,(Subscript[ℒ, t])[f(t)](s)]

Then once we invert, we get the same answer we would get from DSolve:

lapsol = InverseLaplaceTransform[%,s,t]
Expand[%]
dsol = DSolve[{eq3,ic3a,ic3b},f[t],t]
Expand[%]

Exercise

1.  Solve the system y''+4y'+4y=(e^(-2t)), y(0)=0,y'(0)=1 by both Laplace transforms and using DSolve.

Solution

prob3 = y''[t]+4*y'[t]+4*y[t]==Exp[-2*t]
ic4a = y[0]==0
ic4b=y'[0]==1

DSolve[{prob3,ic4a,ic4b},y[t],t]

LaplaceTransform[prob3,t,s]
%/.{y[0]->0,y'[0]->1}
Solve[%,(Subscript[ℒ, t])[y(t)](s)]
InverseLaplaceTransform[%,s,t]

Transforms with the Step Function

In Mathematica, the notation for the unit step function turning on at c [(Subscript[u, c])(t) in the book] is given by HeavisideTheta[t-c].  (There is also a UnitStep function, but Mathematica will provide answers using HeavisideTheta.)

f1 = 3*HeavisideTheta[t-4]

The plot of this will be discontinuous, as expected:

Plot[f1,{t,0,5},PlotRange->{{0,5},{-0.5,3.5}},PlotStyle->Thickness[0.02]]

Mathematica can handle both forward and backward Laplace transforms of step functions without difficulty:

LaplaceTransform[f1,t,s]

t1 = 4*(1-Exp[-2*s])/s^2
InverseLaplaceTransform[t1,s,t]

With this notation, you can now solve differential equations with step forcing:

eq1 = y''[t]+2*y'[t]+3*y[t]==f1
DSolve[{eq1,y[0]==1,y'[0]==0},y[t],t];
Simplify[%]
Plot[y[t]/.%,{t,0,5}]

Note how the solution to the homogeneous problem was decaying away until the forcing began at t=4.

We can also use step functions in more complicated nonlinear equations:

eq2=y''[t]+(y'[t])^2-Sin[3*y[t]]==f1
DSolve[{eq2,y[0]==1,y'[0]==0},y[t],t]

Since we get no answer, we must solve numerically:

f2 = NDSolve[{eq2,y[0]==1,y'[0]==0},y,{t,0,5}];
Plot[y[t]/.f2,{t,0,5}]

Exercises

1.  Calculate the Laplace transform of sin(t)(Subscript[u, 3])(t)+(t^2)(1-(Subscript[u, 4])(t)).

Solution

prob1 = Sin[t]*HeavisideTheta[t-3]+t^2*(1-HeavisideTheta[t-4])
LaplaceTransform[prob1,t,s]

2.  Calculate the general solution of y''+y=sin(t)(Subscript[u, 3])(t)+(t^2)(1-(Subscript[u, 4])(t)).

Solution

prob2 = y''[t]+y[t]==prob1
DSolve[prob2,y[t],t]
Simplify[%]