Euler’s method is a useful tool for estimating a solution to a differential equation initial value problem at a specific point. In this post, I’m going to show you how to apply Euler’s method both on a piece of paper doing calculations by hand, and in an Excel spreadsheet.
Before we jump into the first example I just want to mention that this uses one of the formulas on my Calculus 2 Study Guide (Integral Calculus Cheat Sheet). It’s available for instant download so you can start using it today. You can learn more about that cheat sheet and buy your copy today by clicking here.
How to Apply Euler’s Method With Differential Equations
We will go ahead and start with this first example here. Use Euler’s method with a step size of 0.2 to estimate , where is the solution of the initial-value problem . If you’d prefer to see this example in video form you can watch it here.
I like to solve these problems using a table. I think that’s the easiest way to keep everything you’re doing organized. And then we’re going to use the formula on my study guide to fill in the table row by row until we get to our answer. So let’s just go ahead and start with the formula that’s on my study guide first, and then I’ll show you what I mean by setting up the table.
This is just the information that we would need to be given. We know that we have some initial value problem, where we have . And then we have the initial condition. So, we know that if we plug in , into the solution to the initial value problem, we would get out . Since we know that in this example, we have , that tells us right there that we’re going to have
$$F(x, y) = xy \ – x^2$$
To apply this Euler’s method formula, what we need to do is set this up in a table. And you can kind of think of this table like an Euler’s method differential equation calculator. I will show you how to use a computer to make this easier. But it is important to know how it works so that you can do it manually too.
How to Set Up the Euler’s Method Table
We’re going to need a few different columns in our table to keep track of all the calculations. We’re going to start with a column where we keep track of what n we’re on. We also need columns for our , and our .
Then we also want to calculate what we get when we plug into, our based on the we figured out already. Finally we are going to use all these pieces to figure out our based on the formula discussed earlier from my study guide.
It really is just up to personal preference. If you don’t like keeping of all these columns, you don’t really have to. I like to break it down into the smallest possible pieces, and keep track of each individual piece so that you don’t get lost. I do this and recommend this for you because it’s really easy to get lost when you’re trying to keep track of all these different things.
I like to break it down into, at the smallest possible elements of this formula, and keep track of all those, so that when we put it all together, it’s a lot easier to figure out what’s going on. Doing this will give us the following columns to fill in.
n | ||||
First we want to figure out what you need in the n column. The point that we’re given that we start at is, . So we’re starting at . And what we’re trying to estimate is . That tells us using the given step size of 0.2, we’re going to start with and use Euler’s method to first estimate, what the y value is of this solution when . Then we’re going estimate what the y value is when , then 0.6, then 0.8, and finally when .
To put it in a more formulaic approach, we would take our ending x value minus the starting x value and divide by the step size.
$$n=\frac{x_n – x_0}{step \ size}=\frac{1-0}{0.2}= 5$$
Well, doing this, is going tell us that we need five steps to get from our starting point to our end. So our n column will have one, two, three, four, and five, because that would represent the five, individual steps that we have to take to get up to from .
n | ||||
1 | ||||
2 | ||||
3 | ||||
4 | ||||
5 |
How to Apply Euler’s Method
Now that we have set up our table, we can start applying Euler’s Method to fill the table out. First of all, we need to start with the x and y value that you’re given. We know when , . So you’re just going to start with those in the row and the and columns.
n | ||||
1 | 0 | 1 | ||
2 | ||||
3 | ||||
4 | ||||
5 |
Then what you can do, is plug these two numbers, and into the function that we figured out earlier.
$$F(x, y) = xy \ – x^2$$
$$F(0, 1) = (0)(1) \ – (0)^2 = 0$$
And this will go in the column.
n | ||||
1 | 0 | 1 | 0 | |
2 | ||||
3 | ||||
4 | ||||
5 |
Now with this final column here, , what we can do is use this formula that we have here, which is on my calculus two study guide. This will use the previous columns along with our given step size of 0.2, which is denoted by h.
$$y_n = y_{n-1}+hF(x_{n-1},y_{n-1})$$
$$y_1 = 1+(0.2)(0) = 1$$
And then we can put this in our final column of this first row.
n | ||||
1 | 0 | 1 | 0 | 1 |
2 | ||||
3 | ||||
4 | ||||
5 |
Now that we figured out this, we can just carry this piece down into the next column. Whatever your previous was, is just gonna be your in the next column.
To figure out your next , all you have to do is take your previous and just add whatever your step size is. In this case, our step size is 0.2. We’re just going get 0.2 for in the second row of our table. Doing both of these will give us:
n | ||||
1 | 0 | 1 | 0 | 1 |
2 | 0.2 | 1 | ||
3 | ||||
4 | ||||
5 |
Now Repeat This Process a Few Times
Once you fill out your entire first row, then get the and in your second row, the only thing to do is repeat this process. You will now plug in these two x and y values into the to get the value in the third column. Then plug those into the formula for to get the forth column. Then figure out the and in your third row and continue repeating until your table is full and all 5 rows are filled out. Doing this should leave you with this:
n | ||||
1 | 0 | 1 | 0 | 1 |
2 | 0.2 | 1 | 0.16 | 1.032 |
3 | 0.4 | 1.032 | 0.2528 | 1.08256 |
4 | 0.6 | 1.08256 | 0.289536 | 1.140467 |
5 | 0.8 | 1.140467 | 0.272374 | 1.194942 |
So, after we iterate through this process, all the way up to , we end up getting in 1.194942 in our column. And that should be the answer that they wanted us to find because that should estimate .
How to Apply Euler’s Method in Excel
Turns out, you can also do these Euler’s method problems using Excel or any other spreadsheet software. And it’s a lot easier and faster than doing it by hand. Watch the videos below to see how you can do this yourself to create an Euler’s method calculator to apply Euler’s method in Excel. And don’t forget to get yourself a copy of my integral calculus cheat sheet to help make the rest of your homework and exams easier and smoother!