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

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
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. ## 60 thoughts on “Euler’s method | Differential equations| AP Calculus BC | Khan Academy”

1. Patrick O'Connor says:

Why did you take down the program video?

2. Philip S. says:

Thanks for all that you do on here this is great stuff !! Very Helpful =)

3. Virtually Passed says:

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

4. Bruce Xu says:

This method has limitations, like the sin1/x, it fluctuate rapidly between -0.25 and 0.25

5. LizzieAthey says:

i still dont get how you went from 1.5 to 2.25 in the second table in the y column

6. Alejandro Hervella says:

THANKYOU, I had no idea what my text book was talking about!

7. Paul F.Smith says:

I'm almost understanding 'e' !

8. irregulargamer13 says:

thanks for barely explaining it. Thanks.

9. Ewetubedean says:

The cogs just clicked into place for me, thank you again Khan academy!!!

10. Swati Chow says:

Why do we increase y by the previous dy/dx? ?

11. Michael Portis says:

Why does he sound like a big joke

12. Mehecanogeesir says:

Isn't the last y value in the first chart supposed to be 7 since dy/dx is 4 and x is 3? 4+3=7?

13. Shaurya Sanghvi says:

Sal, I love your videos and wanted to let you know how much I appreciate them. Keep up the good work.

14. Angshuman R Goswami says:

nice

15. V F says:

Look's at Euler's Method described in the textbook [Shudders]

16. Nabaneet Sharma says:

Too hard process for solving difficult differential equations!

17. Arisbeth Laguna says:

forget the way this guy talks???

18. Gleb Khachatryan says:

I just dont understand one thing. Why, in the first example, you straight assume that you multiply "y" by 2?

19. Simo2009BORO says:

What happens if you get to dy/dx is 0? It is a problem I am having!

20. Dan says:

does this guy still post ?

21. Roman Glushenok says:

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

22. Abdelrahman Gamal says:

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 ???

23. Pineapple29 says:

who's here because of Hidden Figures? 😛

24. Bugatti Veyron says:

NO!!!!!! LMAO

25. 006 Delta says:

What software is he using to draw?

26. Derek says:

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.

27. Yung Plague says:

thank you for making it sound more complicated than needed

28. suhara fernando says:

can not understand how u got 2.25 in the second table

29. Erizon Santos says:

This guy reminds me of Bane from Batman

30. Michael Guo says:

Thanks for interpreting the concept!!

31. Melisa Pham says:

Absolutely lost me @5:11…

32. Sayon Pak says:

I think this is wrong

33. Jorker14 Adicto al Pensamiento says:

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

34. Muhtasim Ahmed says:

How do u get y(x)=e^x ?

35. Nels says:

rockin it sal!

36. KOCAMEGI says:

Thanks for translation Arabia

37. jackson jiang says:

He just repeated it's going to look like three times lol 7:54 thought my computer was frozen

38. Stanley Nicholson says:

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.

39. Paul Hong says:

im an internarional student and Khan Academy is super helpful Thank You!

40. Ding Hui Ng says:

Euler is a math genius while Sal is a genius educator😍😍

41. ruslan2336 says:

Very bad. At least show some equations. Error calculation.

42. Ash W says:

Hi isn't it e^2=7.389 & e^3=20.086??

43. Aditya Mukherjee says:

I dont get it.

44. Stephen Ball says:

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!

45. Yuki H says:

0:53 thanks for the motivation

46. Prashanth says:

All hail finite element analysis!!

47. Mohammad Al-Ghafli says:

This makes no sense to me honestly 🙂

48. Royal Gao says:

How’s y equal to 2 when x=1? When x=1, y should be e

49. Joel Rendon says:

why did he add .5 by half of 1.5??? wasn't the pattern to add x to the slope?

50. John Porter says:

I don’t get it, back to watching someone eat

51. Micah Mayers says:

OILER'S METHOD?

52. ejimadam says:

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.

53. Liquidice Slayer says:

wait we don't give up??!?

nooooooooooo

54. Schrödinger says:

Watching this on Euler's Birthday

55. Hunar Omar says:

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?

56. Gimina Gz says:

اخيرا فيديو انجليزي مترجم عربي👍👍😍

57. yair dragon says:

It was very exciting, honest

58. anshul says:

I love you Sal, you're doing God's work

59. Krishna Patel KKP PANNA says:

In hindi

60. yogesh kumar says:

sir can we solve a 2nd order ode using euler or runge kutta 2nd order or 4th order method