Main content

## Differential equations

### Course: Differential equations > Unit 1

Lesson 3: Euler's Method# Euler's method

AP.CALC:

FUN‑7 (EU)

, FUN‑7.C (LO)

, FUN‑7.C.4 (EK)

Euler's method is a numerical tool for approximating values for solutions of differential equations. See how (and why) it works.

## Want to join the conversation?

- How X=1 be Y = 2? because y = e^x, if X = 1, then Y should be e^1(40 votes)
- You are right, the correct point is
`y(1) = e ≅ 2.72`

; Euler's method is used when you cannot get an exact algebraic result, and thus it only gives you an approximation of the correct values. In this case Sal used a`Δx = 1`

, which is very, very big, and so the approximation is way off, if we had used a smaller`Δx`

then Euler's method would have given us a closer approximation.

With`Δx = 0.5`

we get that`y(1) = 2.25`

With`Δx = 0.25`

we get that`y(1) ≅ 2.44`

With`Δx = 0.125`

we get that`y(1) ≅ 2.57`

With`Δx = 0.01`

we get that`y(1) ≅ 2.7`

With`Δx = 0.001`

we get that`y(1) ≅ 2.72`

(149 votes)

- I understand the concept behind Euler's method and it is quite interesting , but I don't get how sal got his values for y ?(53 votes)
- for the first table:

Δx=1

Δy/Δx=y

Δy=y (how much we add to get a new y)

we can write it like: Δy=y(old)

y(new)=y(old)+Δy=2y(old)

-if y=1 then y(new)=2y(old)=2(1)=2

-then y=2 then y(new)=2y(old)=2(2)=4

-then y=4 then y(new)=2(4)=8

for the second table:

Δx=0.5

Δy/Δx=y

Δy/0.5=y

Δy=y/2

Δy=y(old)/2

y(new)=y(old)+Δy=3/2 y(old)

-if y=1 then y(new)=3/2 y(old)=3/2(1)=1.5

-then y=1.5 then y(new)=3/2 y(old)=3/2(1.5)=2.25

-then y=2.25 then y(new)=3/2 y(old)=3/2(2.25)=3.375

...and so on

hope this helps.(17 votes)

- Why does the y-values increment by half of the slope?(23 votes)
- I assume you are talking about the second case. The slope
`dy/dx`

tells us that for a given number of steps on the x axis, we must take a certain number of steps on the y axis. So you should read`dy/dx = 1.5`

as`dy/dx = 1.5/1`

, which means that for one step on the x axis, we go one step and a half on the y axis. We can also say`dy/dx = 1.5/1 = 3/2`

, for every two steps on the x axis, we take three steps on the y axis, this is equivalent.

Lastly we also have`dy/dx = 1.5/1 = 0.75/0.5`

. So when we take half a step on the x axis, we must take 0.75 (three quarters) steps on the y axis.(25 votes)

- For all Euler type problems, is the slope always equal to y?(14 votes)
- No, the slope is always equal to
`dy/dx`

(that is, after all, the definition of slope). In this example,`dy/dx = y`

, but that is not general at all.(31 votes)

- At8:20when x=1, why is that y is incremented by 'half' of dy/dx( 1.5 ) and not 1.5 itself?(8 votes)
- Because our
`Δx = 0.5`

, so we only advance half a unit.`dy/dx = 1.5`

means that an increment of 1 in x would carry an increment of 1.5 in y, but since we are only incrementing x by 0.5, we only increment y by 0.75.(15 votes)

- Isn't this reminiscent of Riemann sums, but like for an arc length rather than an area?(10 votes)
- I was thinking the same thing. As the x intervals get smaller and smaller they approach what is essentially dx, then evaluate it infinitely many times just as you do in an integral. That could be demonstrated using this example, but it may not work with more complicated differential equations that can't be integrated as easily.(7 votes)

- Nice method! Is it based on the linear approximation principle y(x + Δx) ≈ y(x) + y'(x)*Δx ?(10 votes)
- Can some please help me with this method? I'm stuck on this I need some help or explaining to. I'm only in 6th grade but I've watched this video 6 times pausing to take notes and I keep getting stuck on the skill.(5 votes)
- You should probably get strong foundations of high school math (algebra- precalc) and basic calculus before doing this. Calc BC is a more advanced calculus. If you already know high school math, do calc AB, then this will all make sense. I’m glad you’re interested in the subject, though! The world needs more people like that.(1 vote)

- At9:05, Sal says "If we stepped by 0.0001 we would get even closer and closer and closer." What would happen if we took the limit as Δx approaches 0? (A reasonable assumption is that we would get the exact solution if we took the limit, but how would we take that limit?)(4 votes)
- Can Euler's method be used for higher order differential equations ?(2 votes)
- Yes. One typically reduces the higher order differential equation to a system of first order equations, and then use Euler's method on the first order system. You should be able to find the details on Google.(4 votes)

## 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 have 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.