# Euler#

class brainpy.integrators.ode.Euler(f, var_type=None, dt=None, name=None, show_code=False, state_delays=None, neutral_delays=None)[source]#

The Euler method for ODEs.

Also named as Forward Euler method, or Explicit Euler method.

Given an ODE system,

$y'(t)=f(t,y(t)),\qquad y(t_{0})=y_{0},$

by using Euler method , we should choose a value $$h$$ for the size of every step and set $$t_{n}=t_{0}+nh$$. Now, one step of the Euler method from $$t_{n}$$ to $$t_{n+1}=t_{n}+h$$ is:

$y_{n+1}=y_{n}+hf(t_{n},y_{n}).$

Note that the method increments a solution through an interval $$h$$ while using derivative information from only the beginning of the interval. As a result, the step’s error is $$O(h^2)$$.

Geometric interpretation

Illustration of the Euler method. The unknown curve is in blue, and its polygonal approximation is in red : Derivation

There are several ways to get Euler method .

The first is to consider the Taylor expansion of the function $$y$$ around $$t_{0}$$:

$y(t_{0}+h)=y(t_{0})+hy'(t_{0})+{\frac {1}{2}}h^{2}y''(t_{0})+O(h^{3}).$

where $$y'(t_0)=f(t_0,y)$$. We ignore the quadratic and higher-order terms, then we get Euler method. The Taylor expansion is used below to analyze the error committed by the Euler method, and it can be extended to produce Runge–Kutta methods.

The second way is to replace the derivative with the forward finite difference formula:

$y'(t_{0})\approx {\frac {y(t_{0}+h)-y(t_{0})}{h}}.$

The third method is integrate the differential equation from $$t_{0}$$ to $$t_{0}+h$$ and apply the fundamental theorem of calculus to get:

$y(t_{0}+h)-y(t_{0})=\int _{t_{0}}^{t_{0}+h}f(t,y(t))\,\mathrm {d} t \approx hf(t_{0},y(t_{0})).$

Note

Euler method is a first order numerical procedure for solving ODEs with a given initial value. The lack of stability and accuracy limits its popularity mainly to use as a simple introductory example of a numeric solution method.

References