Main content

## Laplace transform to solve a differential equation

Current time:0:00Total duration:18:48

# Using the Laplace transform to solve a nonhomogeneousÂ eq

## Video transcript

It's been over a year since I
last did a video with the differential equations playlist,
and I thought I would start kicking up, making
a couple of videos. And I think where I left,
I said that I would do a non-homogenous linear equation
using the Laplace Transform. So let's do one, as a bit of a
warm-up, now that we've had a-- or at least I've had
a one-year hiatus. Maybe you're watching these
continuously, so you're probably more warmed
up than I am. So if we have the equation the
second derivative of y plus y is equal to sine of 2t. And we're given some initial
conditions here. The initial conditions are y
of 0 is equal to 2, and y prime of 0 is equal to 1. And where we left off--
and now you probably remember this. You probably recently watched
the last video. To solve these, we just
take the Laplace Transforms of all the sides. We solve for the Laplace
Transform of the function. Then we take the inverse
Laplace Transform. If that doesn't make sense, then
let's just do it in this video, and hopefully
the example will clarify all confusion. So in the last video-- it was
either the last one or the previous one-- I showed you that
the Laplace Transform of the second derivative of y is
equal to s squared times the Laplace Transform of y-- and we
keep lowering the degree on s-- so minus s times y of 0. You can kind of think of it
as taking the derivative. This is an integral. It's not exactly the
anti-derivative of this. But the Laplace Transform
it is an integral. The Transform is an integral. So y of 0 is kind of one
derivative away from that. And then minus y prime of 0. And then we could also
rewrite this. And this is just a purely
notational issue. I could write this, instead of
writing the Laplace Transform of y all the time, I could write
this as s squared times capital Y of s-- because this
is going to be a function of s, not a function of y-- minus
s times y of 0 minus y prime y of 0. These are going to be
numbers, right? These aren't functions. These are the function evaluated
at 0, or the derivative of the function
evaluated at 0. And we know what these
values are. y of 0, right here, is 2,
and y prime of 0 is 1. It was given to us. So if we take the Laplace
Transforms of both sides of this equation, first we're
going to want to take the Laplace Transform of this term
right there, which we've really just done. The Laplace Transform of the
second derivative is s squared times the Laplace Transform of
the function, which we write as capital Y of s, minus this,
minus 2s-- they gave us that initial condition--
and then minus 1. Right? This term right here is
just 1, so minus 1. So that's term right there. Then we want to take
the Laplace Transform of y by itself. So this is just plus Y of
s, right, the Laplace Transform of y. So I'll just rewrite Laplace
Transform of y. I'm just rewriting it
in this notation. Y of S. It's good to get used
to either one. This is going to be equal
to the Laplace Transform of sine of 2t. And I showed you in a video last
year that we showed what the Laplace Transform of sine
of at is, but I'll write it down here just so
you remember it. Laplace Transform of the sine
of at is equal to a over s squared plus a squared. So the Laplace Transform
of sine of 2t. Here, a is 2. This is going to be 2 over
s squared plus 4. So if we take the Laplace
Transform of both sides of this, the right-hand side
is going to be 2 over s squared plus 4. Now what we can do is we can
separate out all the Y of s terms. And so we can factor,
well I guess we could say, factor out their coefficients,
so that's a Y of s term, that's a Y of s term. And so we could write the
left-hand side here as s squared-- that's that term--
plus 1-- the coefficient on that term-- s squared plus
1, times Y of s. Let me do it in green. So this is Y of s, and this Y
of s, times Y of s, and then we have the non-Y of s terms.
These two right here. So minus 2s, minus 1, is equal
to 2 over s squared plus 4. We can add 2s plus 1 to both
sides, to essentially move this to the right-hand side, and
we're left with s squared plus 1, times Y of s, is equal
to 2 over s squared plus 4, plus 2s, plus 1. Now we can divide both sides of
this equation by s squared plus 1, and we get the Laplace
Transform of Y. Y of s is equal to-- let me
switch colors-- it's equal to 2 over s squared plus 4 times
this thing right here. I'm dividing both sides of this
equation by this term right there. So times s squared plus 1-- it's
in the denominator so I'm dividing by it-- plus 2s plus
1-- I have to divide both of those terms by the s squared
plus 1-- divided by s squared plus 1, divided by
s squared plus 1. Now, in order to be able to
take the inverse Laplace Transform of this, I need to get
it in some type of simple fraction form. These are actually easier to
do, but this was one's a little bit difficult. I want to do some partial
fraction decomposition to break this up into maybe
simpler fractions. So what I want to do, I'm going
to do a little bit of an aside here. And this really is the hardest
part of these problems. The algebra, breaking
this thing up. So I'm going to break this up. So let me write this this way. 2 over s squared plus 4 times
s squared plus 1. I'm going to break this
up into two fractions. This is the partial fraction
decomposition. One fraction is s
squared plus 4. And the other fraction
is s squared plus 1. And since both of these
denominators are of degree 2, the numerators are going
to be of degree 1. So they're going to be some--
let me write it this way-- this one will be As plus B. And then this one will
be Cs plus D. This is just pure algebra. This is just partial fraction
decomposition. I've made a couple
of videos on it. And I'm saying that I'm assuming
that this expression right here can be broken
up into two expressions of this form. And I need to solve for
A, B, C, and D. So let's see how
we can do that. So if I were to start with these
two and add them up, what do I get? I would have to multiply these
times-- so my denominator, my common denominator, would be
this thing again-- it would be s squared plus 4 times
s squared plus 1. And now I'm going to have to
multiply the As plus B times this s squared plus 1. This, as it is right now,
these two terms would cancel out. You'll just get this term,
but I need to add it to this right here. So you get plus Cs plus D
times s squared plus 4. And now let's see what we could
do to match up the terms here with this number
2 right here. So let's multiply
all of this out. So As times s squared
is As to the 3rd. As times 1 is plus As. B times s squared, so plus Bs
squared, and then you have B times 1 is plus B. And then you have Cs times s
squared, that's Cs to the 3rd. And then Cs times 4,
so it's plus 4Cs. These problems are tiring. And I also have a cold, so this
is especially tiring, but I'll soldier forward. Where was I? So I multiplied the C's times
each of these, now I have to multiply the D's. So plus Ds squared-- that's D
times that one-- plus D times 4, so plus 4D. So that's all of them. And I just wrote it this way
so I have the common degree terms under each other. So if I were to add the entire
numerator, I get-- and I'll just switch colors, somewhat
arbitrarily-- I get A plus C times s to the 3rd plus-- let
me write the s squared term next-- plus B plus D times s
squared-- now I'll write this s term-- plus A plus 4C times
s plus B plus 4D. This is just the numerator. This is when I just added
these two things up. This whole thing up here
simplifies to this. I don't know if the word
simplify is appropriate. But it becomes this expression
right here. And that's just the numerator. The denominator is still what
we had written before. The denominator is still the s
squared plus 4, times the s squared plus 1. Of course, I have to show
that this is a fraction. And this is going to be equal
to this thing over here. 2 over s squared plus 4 times
s squared plus 1. Now, why did I go through this
whole mess right here? Well, the reason why I went
through it is because we should be able to solve
for A, B, C, and D. So let's see, A plus C. This is the coefficient
on the s cubed term. Do we see any s cubed
terms here? No, we see no s cubed
terms here. So A plus C-- let me write this
down-- A plus C must be equal to 0, because we
see nothing here that has an s to the third. B plus D is a coefficient
on the s squared term. Do we see any s squared
terms here? No, so B plus D must
be equal to 0. A plus 4C are the coefficient
of the s term. I see no s term over here. So A plus 4C must also
be equal to 0. And then finally, we look at
just the constant terms. And we do have a constant term
on the left-hand side of this equation. We have 2. so B plus 4D-- I didn't want to
make it that thick-- B plus 4D must be equal to 2. This just seems like these
linear equations are pretty easy to solve for. Let's subtract this from this. So A-- or let me subtract the
bottom one from the top one-- so A minus A, that's 0A. And then C minus 4C minus
3C is equal to 0. And so you get C
is equal to 0. If C is equal to 0, A plus C
is equals to 0, A must be equal to 0. And let's do the same
thing here. Let's subtract this from that. So you get B minus B is 0, and
then minus 3D-- that's just D minus 4D-- and then 0 minus
2 is equal to minus 2. And then you get D is equal to--
what do we get?-- D is equal to 2/3. Minus 2 divided by minus 3 is
2/3, and then-- this isn't a minus here, I wrote that there
later-- we said B plus D is equal to 0. So B must be the opposite
of D, right? We could write B is equal
to minus D, or B is equal to minus 2/3. Let's remember all of this and
go back to our original problem, because we've
kind of-- actually let me just be clear. We can rewrite 2 over s
squared plus 4 times s squared plus 1. We can rewrite this as, well,
A is 0, B is minus 2/3. So this is equal to minus 2/3
over s squared plus 4. And then C is 0, we
figured that out. And then D is 2/3. So plus 2/3 over s
squared plus 1. So all of that work that I just
did, that was just to break up this piece
right here. That was just to break up
that piece right there. And then, of course, we have
these other two pieces here that we can't forget about. So after all of this work,
what do we have? And I'm going to make
sure I don't make a careless mistake here. We get the Laplace Transform
of Y-- as you can see, the algebra is the hardest part
here-- is equal to this first term-- I'm just going back--
this first term, which I've now decomposed into this. So it's minus-- let me write it
this way-- minus 1/3-- and I think you're going to see in
a second why I'm writing this way-- minus 1/3 times 2 over s
squared plus 4, and then plus 2/3 times 1 over s
squared plus 1. And you're probably saying,
Sal, why are you writing it this way? Well you can already immediately
see that this is the Laplace Transform
of sine of 2t. This is the Laplace Transform
of sine of t. So I wanted to write this 2
here, because this is 2, this is 2 squared. This is 1, this is 1 squared. So I wanted to write
it in this form. This was just the first term. We have two more terms
to worry about. I don't want to make
a careless mistake. I have 2s over s
squared plus 1. So let me write that down. So plus 2 times s over s squared
plus 1, plus-- last one-- plus 1 over s
squared plus 1. Now we just take the inverse
Laplace Transform of the whole thing, and then we'll
know what Y is. So, you know, just to remember
the Laplace Transform. So this is going to be
a little inverse. This is going to
be sine of 2t. Let me just write, just so we
have it here, so you know I'm not doing some type of voodoo. The Laplace Transform of sine
of at is equal to a over s squared plus a squared. And the Laplace Transform of
cosine of at is equal to s over s squared plus a squared. Let's just remember those two
things when we take the inverse Laplace Transform of
both sides of this equation. The inverse Laplace Transform of
the Laplace Transform of y, well that's just y. y-- maybe I'll write it as a
function of t-- is equal to-- well this is the Laplace
Transform of sine of 2t. You can just do some pattern
matching right here. If a is equal to 2, then this
would be the Laplace Transform of sine of 2t. So it's minus 1/3 times sine of
2t plus 2/3 times-- this is the Laplace Transform
of sine of t. If you just make a is equal
to 1, sine of t's Laplace Transform is 1 over
s squared plus 1. So plus 2/3 times the sine of
t-- let me do the next one in blue, just because it was
already written in blue-- plus 2 times-- this is the Laplace
Transform of cosine of t. If you make a is equal to 1,
then the cosine t Laplace Transform is s over
s squared plus 1. So 2 times cosine of t-- and
then one last term-- plus-- this is just like this one over
here, this is just the Laplace Transform of sine
of t-- plus sine of t. And we're almost done. We're essentially done, but
there's a little bit more simplification we can do. I have 2/3 times the sign of t
here, and then I have another 1 sine of t here, so I can
add the 2/3 to the 1. What's 2/3 plus 1, or 3/3? It's 5/3. So I can write y of t is equal
to minus 1/3 sine of 2t plus-- these two terms I'm just
going to add up-- plus 5/3 sine of t. And then I have this last term
here, plus 2cosine of t. So this was a hairy problem,
a lot of work. And we saw that the hardest
part really was just the partial fraction decomposition
that we did up here, not making any careless mistakes. But at the end, we got a pretty
neat answer that's not too complicated, that satisfies
this non-homogenous differential equation. We were able to incorporate
the boundary conditions as we did it. Anyway, hopefully you found
that vaguely satisfying. This is a good warm-up
after a year of no differential equations.