next up previous
Next: Modified Euler Method Up: ode Previous: ode

Euler Method

The ordinary differential equation

\begin{displaymath}
\frac{dy(t)}{dt} = \lambda y
\end{displaymath} (1)

with initial condition $y(0) = y_0$ has the solution

\begin{displaymath}
y(t) = y_0 e^{\lambda t}.
\end{displaymath}

Let's call the independent variable ``time''. A numerical approach to the solution starts from the initial time $t = 0$ and steps forward in discrete time steps $h$, namely $t = ih$ for $i = 0,1,2,\ldots{}$. Let $w_i$ denote the approximation to $y(t)$ at $t = ih$. To step forward in time we begin with the finite-difference representation of the derivative, namely,

\begin{displaymath}
\frac{dy(ih)}{dt} \approx \frac{(w_{i+1} - w_i)}{h}.
\end{displaymath}

Using this approximation in the equation gives

\begin{displaymath}
\frac{(w_{i+1} - w_i)}{h} = \lambda w_i
\end{displaymath}

or

\begin{displaymath}
w_{i+1} = w_i + \lambda w_i h = (1 + \lambda h) w_i.
\end{displaymath}

This is a recursion relation (also called a difference equation), allowing us to step the approximate solution forward in time, starting at $t = 0$ with $w_0 = y_0$. The solution is
\begin{displaymath}
w_i = (1 + \lambda h)^i y_0.
\end{displaymath} (2)

In order for this result to be a good approximation, we require that $\lambda h \ll 1$, in which case $(1 + \lambda h)^i \approx
\exp(\lambda h i)$.

The method outlined above is called the Euler method. The more general problem to be solved is

\begin{displaymath}
\frac{dy}{dt} = f(t,y)    \mbox{with $y(a) = y_a$.}
\end{displaymath} (3)

Usually we are interested in the solution $y(b)$ at $t = b$. So we divide the time interval $[a,b]$ into $N$ steps and write

\begin{displaymath}
t_i = a + hi
\end{displaymath}

for $i = 0,1,\ldots{},N$, where

\begin{displaymath}
h = (b - a)/N.
\end{displaymath}

Again we denote the approximate solution as $w_i = y(t_i)$ and approximate the first derivative as a simple (forward) finite difference. The Euler method then gives the recursion relation
\begin{displaymath}
w_{i+1} = w_i + h f(t_i, w_i).
\end{displaymath} (4)

Let's see how the approximation to $y(b)$ improves as $h$ is decreased. To see this we consider the error in the finite difference approximation to the derivative. A Taylor's series expansion gives

\begin{displaymath}
y(t + h) = y(t) + h \frac{dy(t)}{dt} + h^2/2 \frac{d^2y(t)}{dt^2} +
{\cal O}(h^3).
\end{displaymath} (5)

The finite difference approximation we used above amounts to dropping the terms in $h^2$ and higher powers of $h$ on the rhs. Putting $t =
a + hi$ and using the ODE then gives the difference equation

\begin{displaymath}
w_{i+1} = w_i + h f(t_i,w_i) + {\cal O}(h^2).
\end{displaymath}

The Euler method truncates the series after the second term on the rhs. We see that the error made in such an approximation scales with the square of the step size. So if we decrease the step size by a factor of 2 the Euler error in a single step decreases by a factor of 4. Notice, however, that we must then take twice as many steps to reach $t = b$. So the net error decreases by a factor of two when the step size is decreased by a factor of two.

We call the error in the difference equation the local truncation error to distinguish it from the global error in the final result $y(b)$. More generally, with a local truncation error of ${\cal
O}(h^2)$ in each step and $N$ steps, the global error in $y(b)$ is ${\cal O}(h^2 N)$ or ${\cal O}[h(b-a)]$. Since $b-a$ is constant, the error in $y(b)$ is linear in $h$, as we have seen.

When the error in a method decreases as the first power of $h$ we call it a first order method. The Euler method is therefore a first order method.


next up previous
Next: Modified Euler Method Up: ode Previous: ode
Carleton DeTar 2008-12-01