How to Create an Euler’s Method Differential Equations Calculator

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 \(y(1)\), where \(y(x)\) is the solution of the initial-value problem \(y’=xy-x^2, \ y(0)=1\). 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 \(y’ = F(x,y)\). And then we have the initial condition. So, we know that if we plug in \(x=0\), into the solution to the initial value problem, we would get out \(y=1\). Since we know that in this example, we have \(y’ = xy \ – x^2\), 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 \(x_{n-1}\), and our \(y_{n-1}\).

Then we also want to calculate what we get when we plug into, our \(F(x_{n-1}, y_{n-1})\) based on the \(F(x,y)\) we figured out already. Finally we are going to use all these pieces to figure out our \(y_n\) 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\(x_{n-1}\)\(y_{n-1}\)\(F(x_{n-1}, y_{n-1})\)\(y_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, \(x=0\). So we’re starting at \(y(0)\). And what we’re trying to estimate is \(y(1)\). That tells us using the given step size of 0.2, we’re going to start with \(x=0\) and use Euler’s method to first estimate, what the y value is of this solution when \(x=0.2\). Then we’re going estimate what the y value is when \(x=0.4\), then 0.6, then 0.8, and finally when \(x=1\).

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 \(x=1\) from \(x=0\).

n\(x_{n-1}\)\(y_{n-1}\)\(F(x_{n-1}, y_{n-1})\)\(y_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 \(x=0\), \(y=1\). So you’re just going to start with those in the \(n=1\) row and the \(x_{n-1}\) and \(y_{n-1}\) columns.

n\(x_{n-1}\)\(y_{n-1}\)\(F(x_{n-1}, y_{n-1})\)\(y_n\)
101
2
3
4
5

Then what you can do, is plug these two numbers, \(x=0\) and \(y=1\) 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 \(F(x_{n-1}, y_{n-1})\) column.

n\(x_{n-1}\)\(y_{n-1}\)\(F(x_{n-1}, y_{n-1})\)\(y_n\)
1010
2
3
4
5

Now with this final column here, \(y_n\), 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\(x_{n-1}\)\(y_{n-1}\)\(F(x_{n-1}, y_{n-1})\)\(y_n\)
10101
2
3
4
5

Now that we figured out this, we can just carry this piece down into the next column. Whatever your previous \(y_n\) was, is just gonna be your \(y_{n-1}\) in the next column.

To figure out your next \(x_{n-1}\), all you have to do is take your previous \(x_{n-1}\) 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 \(x_{n-1}\) in the second row of our table. Doing both of these will give us:

n\(x_{n-1}\)\(y_{n-1}\)\(F(x_{n-1}, y_{n-1})\)\(y_n\)
10101
20.21
3
4
5

Now Repeat This Process a Few Times

Once you fill out your entire first row, then get the \(x_{n-1}\) and \(y_{n-1}\) 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 \(F(x_{n-1}, y_{n-1})\) to get the value in the third column. Then plug those into the formula for \(y_n\) to get the forth column. Then figure out the \(x_{n-1}\) and \(y_{n-1}\) 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\(x_{n-1}\)\(y_{n-1}\)\(F(x_{n-1}, y_{n-1})\)\(y_n\)
10101
20.210.161.032
30.41.0320.25281.08256
40.61.082560.2895361.140467
50.81.1404670.2723741.194942

So, after we iterate through this process, all the way up to \(n=5\), we end up getting in 1.194942 in our \(y_n\) column. And that should be the answer that they wanted us to find because that should estimate \(y(1)\).

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!

Leave a Reply

Your email address will not be published. Required fields are marked *