The Euler method is a way of approximating solutions to ordinary differential equations. If you're not sure what a differential equation is, see this brief introduction. You will need some understanding of derivatives to understand this article.
An ordinary differential equation is a differential equation that depends on just a single independent variable, which we will call . Suppose you have a function which is unknown. However, suppose you do know that its derivative is a given function of both and the original so it looks like
where the function is known to you. Then the equation (1) is an ordinary differential equation. Solving the differential equation means finding .
For many ordinary differential equations there's no neat formula that gives you its solution. Euler's method helps you find an approximate solution if you do know one initial value. We'll first give the general definition and then look at an example.
First of all, let's suppose there's a number for which we do know the value of ,
Euler's method relies on the fact that for a number whose absolute value is sufficiently small
This follows from the definition of a derivative. We're deliberately being vague about how good the approximation is and how small needs to be, because we just want to get the general idea across.
Euler's method works step by step.
Step 1
Let's set . Then using the fact that we have from (2) above that
Since we know the function and the values of and , we now have approximated the value of at Let's call this approximation , so
Step 2
Now set . Again we have
Since we have
Because we now have two approximations involved, the one saying that and the one coming from (2) above, the overall approximation is probably worse that the one in the first step, but never mind.
Let's set
And so on
You might be able to see where this is going. We could continue for as long as we like, defining and
for successive natural numbers This would give us approximations of The smaller the step size we choose the better the approximations. However, they do get successively worse as we increase the number of steps. To find out more, see the Wikipedia entry.
We can think of all this geometrically. The graph of the function will be a curve sitting in a Cartesian coordinate system. The points , , , etc, we have defined all lie along the -axis with a distance between each pair of successive points. The point lies on the graph of (because that's our know initial point). The points etc, will sit near the graph of (they are the approximations). If we connect successive points by straight line segments we have an approximation of the graph of We have therefore found an approximate solution to our ordinary differential equation.
Euler's method is best implemented on a computer as computations by hand soon become tedious. See here for some code in Python and R that implements Euler's method for the example below, as well as another interesting example: the SIR model that describes the spread of infectious diseases.
Euler's method is the most simple approach to approximating solutions to ordinary differential equation and is the simplest of a whole family of methods called the Runge-Kutta methods. In reality mathematician often use more sophisticated members of this family to reduce the error.
A simple example
Suppose our ordinary differential equation is
and that we know that It's a well-known equation, and you might know that its solution is But let's pretend for a moment that we don't know that and use Euler's method to approximate a solution.
We set so For the step size let's choose so we have
In general, after steps we have
By Euler's method we have
This gives
In general, after steps we have
The points now approximate points on the graph of
We have plotted these points in the Geogebra applet below and connected them by straight line segments (in blue), together with the graph of (in black). We have set as in our example, but you can use the slider to change the value of . You see that as the step size becomes smaller, the approximation gets better. However, for a smaller step size you do need to approximate more points to get an approximation of the graph for the entire segment shown here. This soon becomes very tedious to do by hand, which is why we wrote a bit of code in Geogebra to produce the approximations in an automated way. It's a good illustration of the fact that to solve differential equations, even if it's only approximately, you usually need a computer.
The Euler method is named after the mathematician Leonhard Euler (shown in the image at the top of this article) who first proposed it in his book Institutionum calculi integralis (published 1768–1770).