Main content

## Laplace transform to solve a differential equation

Current time:0:00Total duration:19:12

# Laplace/step function differentialÂ equation

## Video transcript

Let's apply everything we've
learned to an actual differential equation. Instead of just taking Laplace
transforms and taking their inverse, let's actually
solve a problem. So let's say that I have the
second derivative of my function y plus 4 times my
function y is equal to sine of t minus the unit step function
0 up until 2 pi of t times sine of t minus 2 pi. Let's solve this differential
equation, an interpretation of it. And I actually do a whole
playlist on interpretations of differential equations and how
you model it, but you know, you can kind of view this
is a forcing function. That it's a weird forcing
function of this being applied to some weight with, you
know, this is the acceleration term, right? The second derivative with
respect to time is the acceleration. So the mass would be 1 whatever
units, and then as a function of its position, this
is probably some type of spring constant. Anyway, I won't go there. I don't want to waste your time
with the interpretation of it, but let's solve it. We can do more about
interpretations later. So we're going take the Laplace
transform of both sides of this equation. So what's the Laplace
transform of the left-hand side? So the Laplace transform of the
second derivative of y is just s squared, so now I'm
taking the Laplace transform of just that. The Laplace transform of s
squared times the Laplace transform of y minus-- lower the
degree there once-- minus s times y of 0 minus
y prime of 0. So clearly, I must have to
give you some initial conditions in order to
do this properly. And then plus 4 times the
Laplace transform of y is equal to-- what's the Laplace
transform of sine of t? That should be second
nature by now. It's just 1 over s
squared plus 1. And then we have minus
the Laplace transform of this thing. And I'll do a little side note
here to figure out the Laplace transform of this thing
right here. And we know, I showed it to you
a couple of videos ago, we showed that the Laplace
transform-- actually I could just write it out here. This is going to be the same
thing as the Laplace transform of sine of t, but we're going to
have to multiply it by e to the minus-- if you remember that
last formula-- e to the minus cs, where c is 2 pi. Actually, let me write
that down. I decided to write it down,
then I decided, oh, no, I don't want to do this. But let me write that. So the Laplace transform of the
unit step function that goes up to c times some function
shifted by c is equal to e to the minus cs times the
Laplace transform of just the original function times the
Laplace transform of f of t. So if we're taking the Laplace
transform of this thing, our c is 2 pi. Our f of t is just
sine of t, right? So then this is just going to
be equal to-- if we just do this piece right here-- it's
going to be equal to e to the minus cs-- our c is 2 pi-- e to
the minus 2 pi s times the Laplace transform of f of t. f
of t is just sine of t before we shifted. This is f of t minus 2 pi. So f of t is just going
to be sine of t. So it's going to be times
1 over s squared plus 1. This is the Laplace transform
of sine of t. So let's go back to where
we had left off. So we've taken the Laplace
transform of both sides of this equation. And clearly, I have some initial
conditions here, so the problem must have given me
some and I just forgot to write them down. So let's see, the initial
conditions I'm given, and they are written kind of in the
margin here, they tell us-- I'll do it in orange, they tell
us that y of 0 is equal to 0, and y prime of
0 is equal to 0. That makes the math easy. That's 0 and that's 0. So let's see if I can simplify
my equation. So the left-hand side,
let's factor out the Laplace transform. So let's factor out this
term and that term. So we get the Laplace transform
of y times this plus this times s squared plus 4 is
equal to the right-hand side. And what's the right-hand
side? We could simplify this. Well, I'll just write it out. I don't want to do too
many steps at once. It's 1 over s squared plus 1
and then plus-- or minus actually, this is a minus--
minus the Laplace transfer of this thing, which was e to
the minus 2 pi s over s squared plus 1. So if we divide both sides of
this equation by the s squared plus 4, then we get the Laplace
transform of y is equal to-- and actually, I
can just merge these two. They're the same denominator. So before I even divide by
s squared plus 4, that right-hand side will
look like this. It will look like with a
denominator of s squared plus 1 and you have a numerator of 1
minus e to the minus 2 pi s. And, of course, we're dividing
both sides of this equation by s squared plus 4, so we're going
to have to stick that s squared plus 4 over here. Now, we're at the hard part. In order to figure out why, we
have to take the inverse Laplace transform
of this thing. So how do we take the
inverse Laplace transform of this thing? That's where the hard part is
always, you know, it makes solving the differential
equation's easy if you know the Laplace transforms. So it
looks like we're going to have to do some partial fraction
expansion. So let's see if we
can do that. So we can rewrite this
equation right here. Actually, let's write it as
this, because this'll kind of simplify our work. Let's factor this
whole thing out. So we're going to write it as 1
minus e to the minus 2 pi s, all of that times-- I'll do it
in orange-- all of that times 1 over s squared plus 1 times
s squared plus 4. Now, we need to do some partial
fraction expansion to simplify this thing
right here. We're going to do this
on the side. Maybe I should do this over
on the right here. This thing-- let me rewrite it--
1 over s squared plus 1 times s squared plus 4 should be
able to be rewritten as two separate fractions, s squared
plus 1 and s squared plus 4, with the numerators. This one would be As plus B. It's going to have to have
degree 1, because this is degree 2. Here And then we'd
have Cs plus D. And so when you add these two
things up, you get As plus B times s squared plus 4 plus Cs
plus D times s squared plus 1, all of that over the
common denominator. We've seen this story before. We just have to do some
algebra here. As you can tell, these
differential equations problems, they require
a lot of stamina. You kind of just have to say I
will keep moving forward and do the algebra that I need to do
in order to get the answer. And you kind of have to get
excited about that notion that you have all this
algebra to do. So let's figure it out. So this top can be simplified
to As to the third plus Bs squared plus 4As plus 4B. And then this one, you end up
with Cs to the third plus Ds squared plus Cs plus D. So when you add of these up
together, you get-- and this is all the algebra that we have
to do, for better, for worse-- A plus C over s to the
third plus B plus D times s squared plus 4A plus C times s--
let's scroll over a little bit-- plus 4B plus D. And now we just have to say,
OK, all of this is equal to this thing up here. This is the numerator. We just simplified
the numerator. This is the numerator. That's the numerator
right there. And all of this is going to be
over your original s squared plus 1 times your s
squared plus 4. And we established that this
thing should be-- let me just write this-- that 1 over s
squared plus 1 times s squared plus 4 should equal
this thing. And then you just pattern match
on the coefficients. This is all just intense partial
fraction expansion. And you say, look, A plus C is
the coefficient of the s cubed terms. I don't see any
s cubed terms here. So A plus C must
be equal to 0. And then you see, OK, B plus D
is the coefficient of the s squared terms. I don't see any
s squared terms there. So B plus D must
be equal to 0. 4A plus C, the coefficient of
the s terms. I don't see any s terms over here. So 4A plus C must
be equal to 0. And then we're almost done. 4B plus D must be the constant
terms. There is a constant term there. So 4B plus D is equal to 1. So let's see if we can
do anything here. If we subtract this from that,
we get minus 3A is equal to 0, or A is equal to 0. If A is equal to 0, then
C is equals to 0. And let's see what
we can get here. If we subtract this from
that, we get minus 3B. The D's cancel out. It's equal to minus 1,
or B is equal to 1/3. And then, of course, we have D
is equal to minus B, if you subtract B from both sides.
so D is equal to 1/3. So all of that work, and
we actually have a pretty simple result. Our equation, this thing here,
can be rewritten as-- the A disappeared. It's 1/3 over s squared
plus 1. B was the coefficient on the--
let me make it very clear. B was the coefficient on the--
or it was a term on top of the s squared plus 1, so that's
why I'm using B there. And then D is minus B,
so D is minus 1. So let me make sure
I have that. B is 1/3 minus-- let me make
sure I get that right. D is 1/3. So, sorry, B as in boy is
1/3, so D is minus 1/3. So B, there's a term on top
of the s squared plus 1. And then you have minus D over
the minus 1/3 over s squared plus 4. This takes a lot of stamina
to record this video. I hope you appreciate it. OK, so let me rewrite
everything, just so we can get back to the problem because
when you take the partial fraction detour, you forget--
not even to speak of the problem, you forget
what day it is. Let's see, so you get the
Laplace transform of y is equal to 1 minus e to the minus
2 pi s times what that mess that we just solved
for, times-- and I'll write it like this. 1/3 times 1 over s squared
plus 1 minus 1/3 times-- actually, let me write
it this way. Because I have this s squared
plus 4, so I really want to have a 2 there. So I want to have a 2 in the
numerator, so you want to have a 2 over s squared plus 4. So if I put a 2 in the numerator
there, I have to divide this by 2 as well. So let me change this to a 6. Minus 1/6 times 2
is minus 1/3. So I did that just so I get
this in the form of the Laplace transform
of sine of t. Now, let's see if there's
anything that I can do from here. This is an epic problem. I'll be amazed if I don't
make a careless mistake while I do this. So we can rewrite everything. Let's see if we can
simplify this. And by simplifying it, I'm just
going to make it longer. We can write the Laplace
transform of y is equal to-- I'm just going to multiply the
1 out, and then I'm going to multiply the e to the
minus 2 pi s out. So if you multiply the 1 out,
you get 1/3 times 1 over s squared plus 1-- I'm just
multiplying the 1 out-- minus 1/6-- these are all the 1's
times the 1-- times 2 over s squared plus 4. And then I'm going to multiply
the minus e. Let me just switch colors,
do the minus e. So then you get minus e to the
minus 2 pi s over 3 times 1 over s squared plus 1. And then the minus and the minus
cancel out, so you get plus e to the minus 2 pi
s over 6 times 2 over s squared plus 4. Now, taking the inverse Laplace
transform of these things are pretty
straightforward. So let's do that. Let's take the inverse Laplace
transform of the whole thing. And we get y is equal to the
inverse Laplace transform of this guy right here, is just 1/3
sine of t-- I don't have to write a parentheses there--
sine of t, and then this is minus 1/6 times-- this
is the Laplace transform of sine of 2t. That's that term right there. Now, these are almost the same,
but we have this little pesky character over here. We have this e to the
minus 2 pi s. And there, we just have to
remind ourselves-- I'll write it here in the bottom. We just have to remind ourselves
that the Laplace transform of the unit step
function-- I'll put the pi there, just 2 pi times f of t
minus 2 pi-- I should put as the step function of t-- is
equal to e to the minus 2 pi s times the Laplace transform of
just-- or let me just write it this way-- times the Laplace
transform of f of t. So if we view f of t as just
sine of t or sine of 2t, then we can kind of backwards
pattern match. And we'll have to shift
it and multiply it by the unit step function. So I want to make that clear. If you didn't have this guy
here, the inverse Laplace transform of this guy would be
the same thing as this guy. It'd just be sine of t. The inverse Laplace transform
of this guy would be sine of 2t. But we have this pesky
character here, which essentially, instead of having
the inverse Laplace transform just being our f of t, it's
going to be our f of t shifted by 2 pi times the unit
step function, where it steps up at 2pi. So this is going to be minus
1/3 times the unit step function, where c is 2 pi of t
times-- instead of sine of t-- sine of t minus 2pi. And then we're almost done. I'll do it in magenta
to celebrate it. Plus this very last term, which
is 1/6 times the unit step function 2 pi of t, the
unit step function that steps up at 2 pi times sine of-- and
we have to be careful here. Wherever we had a t before,
we're going to replace it with a t minus 2 pi. So sine of, instead of
2t, is going to be 2 times t minus 2 pi. And there you have it. We finally have solved our
very hairy problem. We could take some time
if we want to simplify this a little bit. In fact, we might as well. At the risk of making a careless
mistake at the last moment, let me see if I can make
any simplifications here. Well, we could factor out this
guy right here, but other than that, that seems about as
simple as we can get. So this is our function of t
that satisfies our otherwise simple-looking differential
equation that we had up here. This looked fairly
straightforward, but we got this big mess to actually
satisfy that equation, given those initial conditions
that we had initially.