Euler’s method | Differential equations| AP Calculus BC | Khan Academy
- Articles, Blog

Euler’s method | Differential equations| AP Calculus BC | Khan Academy

– [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.

About James Carlton

Read All Posts By James Carlton

60 thoughts on “Euler’s method | Differential equations| AP Calculus BC | Khan Academy

  1. Is there a value of delta x such that the approximated curve diverges from the actual function? If so, how would you find it?

  2. The Khan Academy helps me a lot of times. That was another one. My appreciation, and please, keep doing that you are really CAN!

  3. Euler's method can only solve first order equations.. Actually I have derived a technique that can solve any differential equation numerically, no matter what order it is..
    Is there any known method that does so, or is it something new I have invented ???

  4. I am sort of new at this stuff.  It would have been nice if he used the formula for Euler's method to do the calculations along with the graph.  Using the formula I got the following results:  Can anybody tell me where I went wrong?Xo=0 Yo=1X1=1, Y1= 1+1(0+1)=2X2=2, Y2= 2+1(1+2)=5X3=3, Y3= 5+1(2+5)=12X4=4, Y5= 12+1(3+12)=27  and so on.

  5. Amazing I finally got it.
    by the way, what is the name of that board-like program you use to explain?

  6. I think for people who are having trouble understanding this (me included) intuitively. Think about this, in the formula for eulers method y_old + Δx (dy/dx). This part of Δx (dy/dx) is just giving us the value of Δy which is then added to the y_old to give us our new y value. It can be derived from Δy/Δx ≈ dy/dx, multiplying by Δx to both sides. But the reason we multiply by Δx is because think about rise over run. For every change in Δx, Δy changes by a specific amount relative to the slope of the line. In the senario when Δx = 0.5 and dy/dx = 1, we are think about how much does "y" change when x changes by 0.5 when the slope is one, giving us Δy = 0.5, this can be applied when dy/dx is equal to different values.

  7. Lmao at people disliking this video because he doesn’t plug-and-chug using a preexisting formula. The derivation for that formula is incredibly simple, especially with this video as a reference. Think harder!

  8. why wasn't the expression just given to find y(n+1)=y(n) + h*y'(x(n),y(n)), where h is the step or delta x. This obviously caused some confusion.

  9. I used the four x,y points that you found in the ∆x=1 .. and put them in a table and found ∆y, ∆^2y, ∆^3y and used the taylor expansion and got (1+x+x^2/2!+x^3/3!) which is exactly e^x .. so for that big ∆x how did i reach that accuracy?

Leave a Reply

Your email address will not be published. Required fields are marked *