Main content

## Integral Calculus

### Course: Integral Calculus > Unit 2

Lesson 5: Approximation with Euler’s method# Worked example: Euler's method

Finding the initial condition based on the result of approximating with Euler's method.

## Want to join the conversation?

- Why doesn't this work backwards?

x y dy/dx = 3x - 2y

2 4.5 3(2) - 2(4.5) = 6 - 9 = -3 => 4.5 - (-3) = 7.5

1 7.5 3(1) - 2(7.5) = 3 - 15 = -12 => 3 - (-12) = 15

0 15

k != 15 != 1.5

:((22 votes)- When approacimating from a correct point, the error starts from small. If you do backwards, the starting point is not a correct point, it's with a huge error already, and then when you go step by step, the error grows even bigger.(48 votes)

- I'm just not getting Euler's Method in practise. I get the theory behind it. I just can't seem to execute it properly. I don't find that examples with step size of 1 very useful because you can't track it backwards (we often skip in examples writing out multiplying by 1 because it's obvious what the answer is). An example with step size 0.5 would more clearly show the process.(13 votes)
- Think of it this way,

dy/dx is essentially the slope at a given point of a function. In euler's method, with the steps, you can say for example, if step is 0.5 (or Delta X, i.e change in x is 0.5), you will have:

dy/dx is given thanks to differential equation and initial condition. You just plug it in and get a value. y1 is the y value at which the slope is the dy/dx and y2 is the y you're looking for. Delta X is change in x , i.e the increment or steps. Or you can think of it as delta X= x2 - x1. But you know the change or steps is 0.5.

dy/dx = (y2-y1)/0.5

You know y1, to find y2 you solve by multiplying

The above is a slope formula, change of y over change of x.(11 votes)

- At2:35Sal says to increment y by -2k. Why do we just add -2k instead of going by the slope..?(7 votes)
- That's simply coming from the slope equation: d𝒚/d𝒙= (𝒚₂-𝒚₁)/(𝒙₂-𝒙₁) = (𝒚₂-𝒚₁)/Δ𝒙, and since the step size or Δ𝒙 is set to be equal 1

then: d𝒚/d𝒙= 𝒚₂-𝒚₁

𝒚₂= (d𝒚/d𝒙) - 𝒚₁

plugging in our given data: 𝒚₂= −2𝒌 - 𝒌 = −𝒌 (and that's where approximation process lies in as you use the previous slope to estimate the next point. Also, as you decrease the step size or Δ𝒙 to infinitely small number, the result is gonna be much more accurate).

If you used the first slope every time you calculate 𝒚₂, you've just assumed the function is a straight line (same slope) and you have no evidence for that except the given equation -the differential equation- for calculating the slope or the derivative of our function. So you must calculate the slope every time you've evaluated 𝒚₂ to know where the curve (or the line) is going next.(4 votes)

- here is how to get the next y(the new y) (just an easy solution made by pattern recognition)

𝒚₂(newy) = (dy/dx * stepsize) + 𝒚₁(oldy)(5 votes) - does dy/dx refer only to the change in y simply because the step size of x is one? what would happen if the step size was .5 or 2?(2 votes)
- To find the change in y (dy), you must multiply dy/dx by dx. Because dx in this problem was 1, dy/dx was the same as dy. However, the step size (dx) was .5, we would have to multiply dy/dx by .5 and then add that value to the previous y-value to get the new y-value.(4 votes)

- At the end of the video (4:00onward), Sal says 3+k = 4.5 and gets k = 1.5... why is that so? What I do not understand here is why y is equal to the slope? In previous steps the function was used, so the calculation for the slope was 3x - 2y. If we implement that here, shouldn't be dy/dx = 3*(2) - 2y = 4.5. Then, if y = 3-k, we get 6 - 2*(3-k) = 4.5, with the result k = 2.25?

Thank you for your help!(3 votes) - how would you answer a questin like this?

let y(x) be the particular solution that contains (0,1). Using Euler's method with step size h=0.5, what is the estimate for y(0.5)?

I don't knowhow to do it because there is no initial condition(2 votes)- Given problem does not present a clue to find the slope of the tangent line at point (0,1). We have to know the differential equation of a function or derivative of function or function itself to figure out the slope.(2 votes)

- What if I start at x=1 but want to find the approximation of f(0) with 2 steps of equal length?(2 votes)
- You'd use the same process.

f(0.5) = f(1) + f'(1, f(1)) * (-0.5)

f(0) = f(0.5) + f'(0.5, f(0.5)) * (-0.5).(2 votes)

- Or you could find the slope at (2, 4.5), subtract that from 4.5 to get g(1). Use that to find the slope at x=1, then subtract that from g(1) to get g(0) which gives 19.5 for k.

It's just using the slope at a higher x-value to determine the y-values at lower x's, whereas Euler's method uses the slope at lower x values to determine the y-values for the higher x's.

Both these methods are completely valid and will approach each other as the step size becomes smaller and smaller.

Using a slope field plotter will show that, in this case, the backwards method is more accurate that the forward method Sal used.(2 votes) - i got to the same result going backwards. I used as a starting point (2; 4.5) and going 1 step backward in x, using the previous slope. Is that a correct aproach?(2 votes)

## Video transcript

- [Voiceover] Now that we are
familiar with Euler's method, let's do an exercise that
tests our mathematical understanding of it, or at
least the process of using it. So, it says consider the
differential equation: the derivative of y with respect to x is equal to three x minus two y. Let y is equal to g of x be a solution to the differential equation
with the initial condition g of zero is equal to
k where k is constant. Euler's method starting at x equals zero with the a step size of
one gives the approximation that g of two is approximately 4.5. Find the value of k. So once again, this is saying
hey, look, we're gonna start with this initial condition
when x is equal to zero, y is equal to k, we're
going to use Euler's method with a step size of one. So, we're essentially going
to use, we're going to step once from zero to one, and
then again from one to two. And then that approximation
is going to give us 4.5. And so, given that we started
at k, we should be able to figure out what k was to get us to g of two being approximated as 4.5. So with that, I encourage
you to pause the video, and try to figure this out on your own. I am assuming you have tried
to figure this out on your own. Now we can do it together. And I'll do the same thing that we did in the first video on Euler's method. I'll make a little table here
so let me make a little table. I can draw a straighter line than that. That's only marginally straighter, but it will get the job done. So let's make this column
x, I'm going to give myself some space for y, I might do some calculation here, y, and then dy/dx. Now, we can start at
our initial condition. When x is equal to zero, y is equal to k. When x is equal to zero, y is equal to k. And so, what's our derivative
going to be at that point? Well, dy/dx is equal
to three x minus two y. So in this case, it's three
times zero minus two times k, which is just equal to negative two k. And so now we can increment one more step. We have a step size of
one, so at each step we're going to increment x by one, and so we're now going to be at one. Now what's our new y going to be? Well, if we increment
x by one, and our slope is negative two k, that means
we're going to increment y by negative two k times
one, or just negative two k. So, negative two k. So k plus negative two k is negative k. So, our approximation using
Euler's method gets us the point one negative
k, and then what is going to be our slope starting at that point? So one negative k, our slope
is going to be three times our x, which is one, minus
two times our y, which is negative k now, and this is
equal to three plus two k. And now we'll do another step of one, because that's our step size. Another, whoops, I'm going to get to two. Now this is the one that
we care about right? Because we're trying to
approximate g of two. So we have to say, what
does our approximation give us for y when x is equal to two? And we're going to have
something expressed in k, but they're saying that's going to be 4.5, and then we can use that to solve for k. So what's this going to be? So if we increment by one in x, we should increment our y by
one times three plus two k. So we're going to increment
by three plus two k, or negative k plus three plus two k is just going to be three plus k. And they're telling us that our approximation gets that to be 4.5. So three plus k is equal to 4.5. So the k that we started
with must have been, if we just subtract three from both sides, this is a decimal here, it must have been k must be equal to 1.5,
and you can verify that. If this initial condition right over here, if g of zero is equal to 1.5,
then you put 1.5 over here. Then over here you would
get 4.5, and we're done.