Improved Euler's Method Algorithm

Shodor > CSERD > Resources > Algorithms > Improved Euler's Method Algorithm

Improved Euler's Method

While simple to understand, Euler's method for integrating ordinary differential equations can have a great deal of numerical error.

Euler's method can be expressed simply as

```    New = Old + Change
```

where the change is determined based on known information at the old time. However, if the rate at which things are changing is also changing over time, this can result in an error. Consider a dropped ball at constant acceleration. The initial velocity of the ball is zero. Clearly if the "change" in the balls position, or the velocity, is assumed to be zero for the entire time step, then the ball will not move at all during the time step. Suppose instead we could use the average of the speed of the ball at the beginning and end of the timestep. This would reduce our error.

The improved Euler method (also called the midpoint Euler method or second order Runge Kutta method) attempts to do just this.

Consider the equation dx/dt = f(x).

What we want is xnew = xold + dt*0.5* (dx/dt|old + dx/dt|new). The problem is that until we know what xnew is, we cannot do this.

So what we do is the following, we shoot forward using dx/dt|old, and use that to create an interim value for xnew.

xnew = xold + dt*0.5* (f(xold) + f(xold+ dt*f(xold))