Lesson Video: Euler’s Method | Nagwa Lesson Video: Euler’s Method | Nagwa

Lesson Video: Euler’s Method Mathematics

In this video, we will learn how to use Euler’s method to approximatesolutions to differential equations.

15:27

Video Transcript

In this lesson, we’ll learn how to use Euler’s method to approximate solutions to differential equations. When we can’t solve a differential equation by analytical methods, we can use what are called numerical methods. From a given starting point, we use it to find repetitive process to approximate a solution to our differential equation. Euler’s method is one such process. We’ll begin by reminding ourselves of the meanings of some of the terms that we’ll use. We’ll then look at how Euler’s method is formulated and go on to see how it works with some examples.

Remember that a differential equation is an equation containing one or more derivatives. The first-order differential equation contains only the first derivative d𝑦 by dπ‘₯. And for an unknown function 𝑦, we have the slope of 𝑦 in terms of the function 𝑓, which can be a function of π‘₯ and 𝑦, a function of π‘₯, or a function of 𝑦. And we might be asked to solve the differential equation d𝑦 by dπ‘₯ is equal to 𝑓 of π‘₯, 𝑦 given the initial value 𝑦 at π‘₯ is equal to zero is 𝑦 zero. This means that our starting point is the point π‘₯ zero, 𝑦 zero. And we’re to use this to find the function 𝑦 of π‘₯. When we do this numerically, we use the point π‘₯ zero, 𝑦 zero to find the value of 𝑦 one, which we then use to find 𝑦 two with our differential equation and so on to 𝑦 𝑛. This gives us our approximation to the function 𝑦 of π‘₯.

Using Euler’s method, we do this by using a series of tangent lines to build up a picture of our solution. Since we’ll be using tangent lines, let’s keep our differential equation in mind but remind ourselves of some fact about straight lines. Suppose we have a straight line through the points π‘₯ zero, 𝑦 zero and π‘₯ one, 𝑦 one. The slope of this line π‘š is equal to 𝑦 one minus 𝑦 zero over π‘₯ one minus π‘₯ zero. Rearranging this we have 𝑦 one minus 𝑦 zero is equal to π‘š times π‘₯ one minus π‘₯ zero. This gives us 𝑦 one equal to 𝑦 zero plus π‘š times π‘₯ one minus π‘₯ zero. Now, if we go back to our differential equation, we know that the slope of 𝑦, d𝑦 by dπ‘₯, is equal to 𝑓 of π‘₯ 𝑦 so that at the point π‘₯ zero, 𝑦 zero, the slope π‘š is equal to 𝑓 of π‘₯ zero, 𝑦 zero. And for our line through the points π‘₯ zero, 𝑦 zero and π‘₯ one, 𝑦 one, we have 𝑦 one equal to 𝑦 zero plus 𝑓 of π‘₯ zero, 𝑦 zero times π‘₯ one minus π‘₯ zero.

And now, if we call the distance between π‘₯ zero and π‘₯ one β„Ž, we have 𝑦 one equal to 𝑦 zero plus β„Ž times 𝑓 of π‘₯ zero, 𝑦 zero. So we can calculate the value of 𝑦 one from knowing 𝑦 zero, β„Ž, and 𝑓 of π‘₯ zero 𝑦 zero. Let’s see how this works on a graph of the function 𝑦. We have our starting point on the graph 𝑦 of π‘₯, which is π‘₯ zero, 𝑦 zero. We draw a tangent line to the curve at π‘₯ zero, 𝑦 zero. And we know that the slope of this line is 𝑓 of π‘₯ zero, 𝑦 zero. If we continue this line to where it meets the vertical with π‘₯ one, which is the distance β„Ž from π‘₯ zero, this gives us the value 𝑦 one. Now, if we draw a tangent to the curve 𝑦 at the point π‘₯ one, 𝑦 one, this tangent has the slope 𝑓 of π‘₯ one, 𝑦 one. If this tangent then meets the vertical at π‘₯ two, which is the distance β„Ž from π‘₯ one, we can find 𝑦 two, in terms of 𝑦 one, β„Ž, and 𝑓 of π‘₯ one, 𝑦 one.

If we continue in this way for a specified number of steps 𝑛 up to π‘₯ 𝑛, on a specified step size β„Ž we find 𝑦 𝑛 is equal to 𝑦 𝑛 minus one plus β„Ž times 𝑓 of π‘₯ 𝑛 minus one 𝑦 𝑛 minus one. And in this way, we find an approximation to 𝑦 of 𝑓 π‘₯ which is a solution to the differential equation. It’s important to remember that we’re actually approximating a solution to the given differential equation. If our step size is quite large, our approximation might be quite far away from the actual solution function 𝑦 of π‘₯. We can increase the accuracy of our solution by decreasing the step size. Now, let’s see how this works with an example.

Consider the initial value problem 𝑦 prime is four π‘₯ minus three 𝑦 where 𝑦 at π‘₯ equal to zero is negative one. Use Euler’s method with 𝑛 equal to five steps on the closed interval zero one to find the value of 𝑦 at π‘₯ is equal to one.

We’ve actually been given a differential equation 𝑦 prime is equal to four π‘₯ minus three 𝑦 and an initial value 𝑦 at π‘₯ is equal to zero is negative one. This means that our starting point for Euler’s method is the point π‘₯ zero, 𝑦 zero which is equal to zero, negative one. We also know that we have five steps and that our closed interval zero, one means that zero is less than or equal to π‘₯ is less than or equal to one. So we have 𝑛 equal to five and zero less than or equal to π‘₯ less than or equal to one.

We’re asked to use Euler’s method to find the value of 𝑦 at π‘₯ is equal to one. To do this, the first thing we need to do is to find the value of β„Ž. That’s our step size. Now, β„Ž is the interval width divided by the number of steps, in our case, the interval where there’s a maximum π‘₯ value one minus the minimum π‘₯ value zero which is one. The number of steps is five. So our step size is one over five. Let’s just sketch our Interval so that we can refer to it throughout our calculations. Our first π‘₯ value is zero, which is π‘₯ zero. Our step size is one over five, which is 0.2. So our next point π‘₯ one is 0.2. Our next π‘₯ value π‘₯ two is 0.4, π‘₯ three is 0.6, π‘₯ four is 0.8, and π‘₯ five is one.

And remember, we’re being asked to calculate the value of 𝑦 at π‘₯ is equal to one. So that’s 𝑦 of π‘₯ five, which is 𝑦 five. So we’re going to use Euler’s method to calculate 𝑦 five. We can’t go directly to 𝑦 five because the only value we have is π‘₯ zero, 𝑦 zero. So we start at this point and calculate 𝑦 one, 𝑦 two, then 𝑦 three, then 𝑦 four, and then 𝑦 five. So to use the formula, we need to know the value of π‘₯ zero, 𝑦 zero, which is zero, negative one. We need to know β„Ž, which is 0.2, and we need to know what the function 𝑓 of π‘₯, 𝑦 is. In our differential equation, 𝑦 prime, which is d𝑦 by dπ‘₯, is equal to four π‘₯ minus three 𝑦. So 𝑓 of π‘₯ 𝑦, in our case, is four π‘₯ minus three 𝑦.

We know that 𝑦 zero is equal to negative one. And we can use this to find 𝑦 one. And in the formula, if 𝑛 is equal to one, then 𝑛 minus one is equal to zero so that 𝑦 one is equal to 𝑦 zero plus β„Ž times 𝑓 of π‘₯ zero, 𝑦 zero. We know that 𝑦 zero was negative one and that β„Ž is 0.2. So we need to find 𝑓 of π‘₯ zero, 𝑦 zero. In our differential equation, 𝑓 of π‘₯ zero, 𝑦 zero is four π‘₯ zero minus three 𝑦 zero. And that’s equal to four times zero minus three times negative one, which is equal to three, so that 𝑦 one is equal to negative one plus 0.2 times three, which is negative 0.4. Now, we can use 𝑦 one to calculate 𝑦 two.

We know that 𝑦 one is equal to negative 0.4. We know that β„Ž is 0.2. So we need to work out 𝑓 of π‘₯ one, 𝑦 one. And that’s equal to four π‘₯ one minus three 𝑦 one. And since π‘₯ one is 0.2, that’s four times 0.2 minus three times negative 0.4, which is 0.8 plus 1.2 which is two. So 𝑦 two is equal to negative 0.4 plus 0.2 times two which is actually zero. Now, if we put 𝑛 equal to three in our formula, 𝑦 three is equal to 𝑦 two plus β„Ž times 𝑓 of π‘₯ two 𝑦 two. We know that 𝑦 two is equal to zero and β„Ž is 0.2. So we need to work out 𝑓 of π‘₯ two 𝑦 two. And that’s equal to four π‘₯ two minus three 𝑦 two. And since π‘₯ two is 0.4, that’s four times 0.4 minus three times zero, which is 1.6. So we have 𝑦 three equal to zero plus 0.2 times 1.6, which is 0.32.

Now, with 𝑛 equal to four, we have 𝑦 four is equal to 𝑦 three plus β„Ž times 𝑓 of π‘₯ three, 𝑦 three. 𝑓 of π‘₯ three 𝑦 three is four π‘₯ three minus three 𝑦 three. So we have four times 0.6 minus three times 0.32 which is 1.44, so that 𝑦 four is equal to 0.32 plus 0.2 times 1.44 and that’s 0.608. And finally with 𝑛 equal to five in our formula, we have 𝑦 five equal to 𝑦 four plus β„Ž times 𝑓 of π‘₯ four 𝑦 four. 𝑓 of π‘₯ four 𝑦 four is equal to four π‘₯ four minus three 𝑦 four. And that’s equal to four times 0.8 minus three times 0.608 which is 1.376 so that we have 𝑦 five equal to 0.608 plus 0.2 times 1.376. And that’s equal to 0.8832. And remember that it’s exactly 𝑦 five that we’re looking for because this is the value of 𝑦 at π‘₯ is equal to one, so that 𝑦 of one is 0.8832.

Now let’s plot our approximation to the function 𝑦, using the points that we found. The graph shown is a computer-generated solution of the differential equation 𝑦 prime is four π‘₯ minus three 𝑦 with initial value π‘₯ zero, 𝑦 zero is zero, negative one. And these are the points that we found using Euler’s method to find an approximation to the solution. If we plot our points on the graph, we can see it’s a very good approximation to the computer-generated solution.

In our next example, we’ll look at a derivative or slope, which is a function of π‘₯ only. And then we’ll compare different solutions, which have used different step sizes for the approximations.

Consider the initial value problem 𝑦 prime is three π‘₯, where 𝑦 at π‘₯ is equal to zero is equal to one. Use Euler’s method with 𝑛 equal to five steps on the closed interval zero, one to find 𝑦 at π‘₯ is equal to one.

We’ve been given a differential equation 𝑦 prime is three π‘₯ so that 𝑦 prime, which is d𝑦 by dπ‘₯, is equal to three π‘₯. We have an initial value 𝑦 at π‘₯ is equal to zero is equal to one, which means that our starting point π‘₯ zero, 𝑦 zero is zero one. We have 𝑛 equals to five steps and the closed interval zero, one. This means that zero is less than or equal to π‘₯ is less than or equal to one. And we’re asked to use Euler’s method to find the value of 𝑦 at π‘₯ is equal to one. In order to use this formula, we need to know the value of β„Ž, which is the step size. And that’s given by the interval width divided by the number of steps. In our case, the interval width is a maximum π‘₯ minus the minimum π‘₯ which is one minus zero divided by the number of steps which is five. That’s one over five, which is 0.2.

Let’s just sketch our interval, so we can refer back to it in our calculations. Since our step size is 0.2 and π‘₯ zero is equal to zero, π‘₯ one is equal to 0.2. Similarly, π‘₯ two is equal to 0.4, π‘₯ three is 0.6, and π‘₯ four is 0.8, and π‘₯ five, which is our maximum value is one. Remember, we’re trying to find the value of 𝑦 when π‘₯ is equal to one. And that’s 𝑦 of π‘₯ five. And we call that 𝑦 five. In order to use the formula, we need to know what our function 𝑓 is. And from our differential equation, we can see that d𝑦 by dπ‘₯ is equal to 𝑓 of π‘₯ is three π‘₯. So if this is a function of π‘₯ only, this means we can delete the second variable 𝑦 in our function 𝑓 in Euler’s formula, so that our formula is 𝑦 𝑛 is equal to 𝑦 𝑛 minus one plus β„Ž times 𝑓 of π‘₯ 𝑛 minus one, where 𝑓 of π‘₯ 𝑛 is three π‘₯ 𝑛. So we have everything we need to use the formula.

We know that 𝑦 zero is equal to one, so we can use the formula to calculate 𝑦 one. And that’s equal to 𝑦 zero plus β„Ž times 𝑓 of π‘₯ zero. We know the value of 𝑦 zero, which is one, and we know the value of β„Ž, which is 0.2. So we need to work out 𝑓 of π‘₯ zero. From our differential equation, that’s equal to three times π‘₯ zero, which is three times zero, which is zero so that 𝑦 one is equal to one plus 0.2 times zero, which is one. And we can use this in our formula to calculate 𝑦 two, which is equal to 𝑦 one plus β„Ž times 𝑓 of π‘₯ one. And we need to work out 𝑓 of π‘₯ one. That’s equal to three times π‘₯ one from our differential equation. And from our interval, we know that π‘₯ one is equal to 0.2. So we have three times 0.2 is equal to 𝑓 of π‘₯ one, and that’s 0.6.

So 𝑦 two is equal to one plus 0.2 times 0.6 which is equal to 1.12. We use this to find 𝑦 three, which is 𝑦 two plus β„Ž times 𝑓 of π‘₯ two, where 𝑓 of π‘₯ two is three times π‘₯ two and π‘₯ two is 0.4, so that 𝑓 of π‘₯ two is 1.2. 𝑦 three is then 1.12 plus 0.2 times 1.2, which is 1.36. We use this to calculate 𝑦 four which is 𝑦 three plus β„Ž times 𝑓 of π‘₯ three and 𝑓 of π‘₯ three is three times π‘₯ three. From our interval, π‘₯ three is 0.6. So that’s three times 0.6, which is 1.8. And we have 𝑦 four equal to 1.36 plus 0.2 times 1.8, which is 1.72. Now, we use this in our final step to calculate 𝑦 five, where 𝑦 five is equal to 𝑦 four plus β„Ž times 𝑓 of π‘₯ four which is three π‘₯ four. And since π‘₯ four is 0.8 from our interval, 𝑓 of π‘₯ four is three times 0.8, which is 2.4. So 𝑦 five is equal to 1.72 plus 0.2 times 2.4, which is 2.2. Remember that 𝑦 five is equal to 𝑦 at π‘₯ is equal to one, which we’ve just calculated as 2.2. So 𝑦 at π‘₯ is equal to one is 2.2.

In our example, we were given 𝑛 equal to five steps on the closed interval zero, one. This resulted in the step size of 0.2. From an initial value of π‘₯ zero, 𝑦 zero, which is equal to zero one, we calculated all the steps up to π‘₯ five, 𝑦 five and arrived at one, 2.2. The graph shown gives a computer-generated solution to the differential equation and our approximated solution with the five points that we calculated. Now, let’s see what happens if we decrease the step size. With 𝑛 equal to 10 in the step size of 0.1 now, we have five extra points. On our graph, we can see that the approximation with the smaller step size is closer to the computer-generated solution. So when the step size is smaller, the approximate solution is closer to the actual solution, although notice that we needed to do more iterations in our calculation.

Let’s summarize now what we’ve covered in Euler’s method. We’ve been looking at Euler’s method for first-order differential equations, which is a numerical method for solving first-order differential equations of the form d𝑦 by dπ‘₯ is 𝑓 of π‘₯, 𝑦 or d𝑦 by dπ‘₯ is 𝑓 of π‘₯ or d𝑦 by dπ‘₯ is 𝑓 of 𝑦. In order to solve, we’re given an initial value, which is 𝑦 at π‘₯ equal to π‘₯ zero. And that’s equal to 𝑦 zero, so that from our starting point π‘₯ zero, 𝑦 zero, we have 𝑛 steps in the interval π‘₯ zero to π‘₯ 𝑛. We use the formula 𝑦 𝑛 is equal to 𝑦 𝑛 minus one plus β„Ž times 𝑓 of π‘₯ 𝑛 minus one 𝑦 𝑛 minus one to find successive values of 𝑦, in order to form an approximation to the solution 𝑦 of π‘₯. β„Ž is the step size, which is the interval width divided by the number of steps. And we know that the smaller the step size β„Ž, the more accurate the approximation. But this means more iterations will be necessary.

Join Nagwa Classes

Attend live sessions on Nagwa Classes to boost your learning with guidance and advice from an expert teacher!

  • Interactive Sessions
  • Chat & Messaging
  • Realistic Exam Questions

Nagwa uses cookies to ensure you get the best experience on our website. Learn more about our Privacy Policy