Introduction & Motivation


Consider the following initial value problem (IVP): (perhaps from a perspective where is a dynamical variable, and is the time elapsed.)

Our aim is to 'solve' this problem. Analytically, this means that we would like to find a closed form expression for the function . However, we find that most differential equations may not have simple analytical expressions for their solutions. This motivates us to look for a numerical solution instead where we trade the knowledge of an analytical expression in exchange for the values of the function at a finite number of time-points .

To begin with, this involves breaking our domain into a discrete set of values, . In general, the spacing between need not be constant, but for starters, let us say they are evenly spaced. This produces a set of discrete values constructed like so (an arithmetic progression):

Hence, solving this problem is equivalent to obtaining the values

Euler's method is our first (and simplest) attempt to numerically approximate the solution of this differential equation. After obtaining these values, we can apply specialised interpolation schemes to construct our version of the true solution.


The Euler method


From the first principle of derivatives, we have

We can discretize this, keeping in mind that ;

Denoting , the equation can be rearranged to give the value of in terms of like so;

The above equation gives an iterative scheme, called the forward Euler method.


A graphical perspective

With a plot, this process can be visualised in a more intuitive manner. In the graph shown below, there is a smooth blue curve which is the solution to some IVP . The dots on the curve represent the points , at which we would like to numerically approximate the solution. Using the iteration scheme shown above, the approximate solution at the specified points are shown in red.

image

Notice that the numerical solution diverges from the analytical solution for larger . This is due to a poorly chosen spacing, between the discrete points, which results in an accumulation of error (ideally, we would require ).


Numerical errors

While performing any numerical operation, it is necessary to obtain some information about the numerical errors that we introduce by using these approximate iterative schemes to gauge the utility of our approximate solution. For the euler method with fixed discretization, the error analysis involved is fairly straightforward.

We begin with the taylor expansion of our function about , truncated upto first order;

Locally, we see that the error drops off quadratically with . However, we perform this iterative scheme times, where .

So, globally the error accumulated is .


Implementation

Check out these links to find language-specific implementations of the euler method.

JuliaPython