# Euler's Method of Integration

## Required Reading

This is the very beginning of computation physics. In most course, 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. Read "Classical Mechanics, the Theoretical Miminum" by Leonard Susskind and George Hrabovsky. This book contains succinct introductions to both ordinary and partial differential equations. You will find the basics of computational physics intuitive.

## Derivation

Consider first order ordinary differential equations of the form

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

Take the Taylor expansion of

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

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

\begin{equation} \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} \end{equation}.

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**:

\begin{equation} \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} \end{equation}.

## Error Terms

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

\begin{equation} N = \frac{x_{j} - x_{i}}{\Delta x} \label{euler_N} \end{equation}.

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

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

The total error over the interval is therefore

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

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.