Current time:0:00Total duration:10:08

0 energy points

# Euler's method

Video transcript

- [Voiceover] We've already seen that if we were to start with
the differential equation, the derivative of Y with
respect to X is equal to Y and we have the initial condition that Y of zero is equal to one, but the particular solution to this given these initial conditions, is Y of X is equal to E to the X. Or I guess we can just
Y is equal to E of the X if we didn't want to write it
with the function notation. And that's all fair and well and this works out well. This is a separable differential equation and we can integrate things quite easily. But as you will see as you
go further in the world of differential equations, most differential equations
are not so easy to solve. In fact, many of them
are impossible to solve using analytic methods. And so given that, what do you do? We've nicely described some phenomena, modeled some phenomena using the differential equations but if you can't solve it analytically do you just give up? And the answer to that question is no. You do not just give up because we now have computers, and computers are really
good at numerical methods. Numerical methods for approximating and giving us a sense of what the solution to a differential
equation might look like. And so how do we do that? Well, in this video we can explore one of the most straightforward
numerical methods for approximating a particular solution. So what we do is, so I'm gonna draw a little table here. So, a little table here. Actually let give myself. I'm gonna do it over here
on the left hand side. A little table. So, X and then Y. XY. And then DY, DX. And you could set up a table like this to create a slope field. You could just pick all the ... You could sample X as in Y in the XY plane, and then figure out for our first order differential equation like this, what is the slope going
to be at that point and you could construct a slope field. And we're gonna do
something kind of related but instead of trying to
construct a slope field, we're gonna start with
this initial condition. We know that Y of zero is equal to one. We know that the particular solution of this differential
equation contains this point. So, we're gonna start with that point. So we're gonna start
with X is equal to zero and let me do this in a different color. We're gonna start with X is equal to zero, Y is equal to one. Which is that point right over there. And we're gonna say, well, okay what is the derivative at that point? Well, we know the derivative at any point that's for any solution to
this differential equation the derivative is going to
be equal to the Y value. So in this case, the derivative is going to be equal to Y. It's going to be equal to one. And in general, if the derivative just like what we saw in
the case of slope fields, as long as the derivative
is expressed as a function of Xs and Y of Xs, then you can figure out what the slope of the tangent line will be at that point. And so, you say okay,
there's a slope of one at that point so I can
depict it like that. And instead of just keep doing
that with a bunch of points we'll say okay, well let's just ... We know that the slope is changing or it's probably changing for most cases. But let's just assume it's
fixed until our next X and then use that assumption to estimate what the next Y would be. So, what am I talking about here? So, when I talk about the next X we're talking about well, let's just step. Let's just say for the sake of simplicity, we're gonna have a delta X of one. A change in X of one. So we're gonna step
from X equals zero now. We're gonna now step from that to X is equal to one. So we're now gonna go to ... Actually I may not use that. I used that yellow color
already for the actual graph or for the actual E to the X. So now let's say X is equal to one. Our delta X is one. So we've just added one here. And what we can do in our little approximation scheme here is well, let's just assume
that that slope was constant over that interval. So where does that get us to? Well, if Y was at one and
if I have a slope of one for one more, for one increase in X, I'm gonna increase my Y by one. So then Y is going to increase by one and is going to get to two. And we see that point right over there and you already might
see where this is going. Now, if this were actually
a point on the curve, on the solution, and if it was satisfying this, what would then the derivative be? Well, the derivative is equal to Y. The slope of the tangent line is going to be equal to Y. So, in this case, the
slope of the tangent line is now going to be equal to two. And we could depict that. Let me depict that in magenta here. So, it is going to be two. It's gonna look ... So the slope of the tangent line there is going to be two. And so, what does that tell us? Well if we step by our delta X one more. So now our X is equal to two. What should the corresponding Y be? Well, let's see. Now for every one that we
increase in the X direction we should increase two in the Y direction because the slope is two. So, the very next one should be four. Y is equal to four. So, we could imagine we have now kind of had a constant slope when we get to that
point right over there. And now we can do the same thing. Well if we assume DY, DX based on the differential
equation it has to be equal Y, okay, the slope of the tangent line there is going to be the same thing as Y. It's going to be four. And so, if we step our X up by one, if we increment our X by one again, once again, we just decided
to increment by one. We could have incremented by 10, we could have incremented by .01. And you could guess which
one's going to give you a more accurate result. But if we step up by one now and our slope is four, well, we're gonna increase by ... If we increase X by one we're gonna increase Y by four. So we are going to get to eight. And so, we are at the
point three comma eight which is right over here. And so, for this next stretch, the next stretch is
going to look like that. And as you can see just by doing this, we haven't been able to approximate what the particular solution looks like and you might say, "Hey, so how do we know "that's not so good of an approximation?" And my reply to you is well, yeah I mean, depends on what your goals are. But I did this by hand. I didn't even do this using a computer. And because I wanted to do it by hand I took fairly large delta X steps. If I wanted a better approximation I could have lowered the delta X and let's do that. So let's take another scenario. So let's do another scenario where instead of delta X equal one, let's say delta X equals 1/2. So once again, X, Y and the derivative of Y with respect to X. So now let's say I want to take ... So we know this first point. We're given this initial condition. When the X is zero, Y is one and so the slope of the tangent
line is going to be one. But then if we're incrementing by 1/2 so then when X is, I'll
just write it as 0.5. 0.5. What is our new Y going to be? Well we're gonna assume that our slope from this to this is this
slope right over here. So our slope is one, so
if we increase X by 0.5 we're gonna increase Y by 0.5 and we're going to get to 1.5. So, we can get 0.5, 1.5. We get to that point right over there. Actually you're having
trouble seeing that. This stuff right over here
is this point right over here and now our new slope is going to be 1.5. Which is going to look like. Which is going to look like
actually not quite that steep. I don't want to overstate
how good an approximation is and it's starting to
get a little bit messy but it's gonna look something like that. And what you would see if
you kept doing this process, so if your slope is now 1.5, when you increment X by another 0.5 where you get to one. So now if you increment by 0.5 and your slope is 1.5, your Y is going to increment
by half of that by 0.75 and so, you're gonna get to 2.25. So now you get to one, 2.25 which is this point right over here. Once again, this is a
better approximation. Remember, in the original one Y of one you know should be equal to E. Y of one in the actual
solution should be equal to E. 2.7 on and on and on and on and on. Now in this one, Y of one got us to two. In this one Y of one got us to 2.25. Once again, closer to the
actual reality, closer to E. Instead of stepping by 0.5, if we stepped by 0.1 we
would get even closer. If we stepped by 0.0001 we would get even closer and closer and closer. So there's a bunch of
interesting things here. This is actually how most
differential equations or techniques that are derived from this or that are based on numerical methods similar to this are how most differential
equations gets solved. You know it's not the exact same solution or the same method that the idea that most differential
equations are actually solved or I guess you can say simulated with a numerical method because most of them
actually cannot be solved in analytical form. Now you might be saying,
"Hey, well what method is "this one right over here called?" Well, this right over
here is called Euler's. Euler's Method after the famous Leonhard Euler. Euler's Method. And not only actually
is this one a good way of approximating what the solution to this or any differential equation is, but actually for this differential
equation in particular you can actually even use this to find E with more and
more and more precision. Anyway, hopefully you found that exciting.