# Euler's Method of Integration

This is the very beginning of computational physics. In most courses, Euler's method is the very first thing you learn because it's so simple. However, it is advantageous to have some working knowledge of calculus first.

## Derivation

Consider first order ordinary differential equations of the form

$$\frac{df}{dx} = g(x,f(x)). \label{ode1}$$

Take the Taylor expansion of

$$f(x + \Delta x) = f(x) + \frac{df(x)}{dx}\Delta x + \frac{d^2 f(x)}{d x^2}\frac{\Delta x^2}{2} + \frac{d^3 f(x)}{dx^3}\frac{\Delta x^3}{6} \cdots \label{taylor}$$

and, expressing the higher-order terms as a lower bound, rewrite equation \eqref{taylor} as

\eqalign{ f(x + \Delta x) & = f(x) + \frac{df(x)}{dx} \Delta x + O(\Delta x^2)\cr & = f(x) + g(x, f(x)) + O(\Delta x^2).} \label{ode2}

Now we devise an integration scheme which solves a first order ordinary differential equation given an initial value $f(x_0)$.

Choose a reasonable value for $\Delta x$; the size will depend on the problem at hand. In general, a smaller $\Delta x$ will result in greater accuracy at the expense of efficiency.

Evaluate each $f(x_i)$ sequentially until $x = x_{\text{final}}$. Equation \eqref{euler} shows the steps involved in the integration scheme known as Euler's method:

\eqalign{ x_{i+1} & = x_{i} + \Delta x \cr f(x_{i+1}) & = f(x_i) + g(x_{i}, f(x_{i})) \Delta x.} \label{euler}

## Error Terms

Integration of the interval $x_{i}$ to $x_{j}$ with a step size of $\Delta x$ would lead to $N$ steps where

$$N = \frac{x_{j} - x_{i}}{\Delta x}. \label{euler_N}$$

Taking the neglected higher order terms from \eqref{ode2}, write the error of a single step as

$$E_1 = O(\Delta x^2) = O(\frac{1}{N^2}). \label{euler_E1}$$

The total error over the interval is therefore

$$E_T = N \cdot O(\frac{1}{N^2}) = O(\frac{1}{N}). \label{euler_ET}$$

Increasing $N$ (decreasing $\Delta x$) leads to a decreased error. However, the error only decreases linearly with respect to $N$, meaning that Euler's method converges toward the real solution slowly.

Due to the leading error term of $O(\Delta x^2)$, Euler's method is considered as a first order integrator.