class brainpy.integrators.fde.Caputo.CaputoEuler(f, alpha, num_memory, inits, dt=None, name=None, state_delays=None)[source]#

One-step Euler method for Caputo fractional differential equations.

Given a fractional initial value problem,

\[D_{*}^{\alpha} y(t)=f(t, y(t)), \quad y^{(k)}(0)=y_{0}^{(k)}, \quad k=0,1, \ldots,\lceil\alpha\rceil-1\]

where the \(y_0^{(k)}\) ay be arbitrary real numbers and where \(\alpha>0\). \(D_{*}^{\alpha}\) denotes the differential operator in the sense of Caputo, defined by

\[D_{*}^{\alpha} z(t)=J^{n-\alpha} D^{n} z(t)\]

where \(n:=\lceil\alpha\rceil\) is the smallest integer \(\geqslant \alpha\), Here \(D^n\) is the usual differential operator of (integer) order \(n\), and for \(\mu > 0\), \(J^{\mu}\) is the Riemann–Liouville integral operator of order \(\mu\), defined by

\[J^{\mu} z(t)=\frac{1}{\Gamma(\mu)} \int_{0}^{t}(t-u)^{\mu-1} z(u) \mathrm{d} u\]

The one-step Euler method for fractional differential equation is defined as

\[y_{k+1} = y_0 + \frac{1}{\Gamma(\alpha)} \sum_{j=0}^{k} b_{j, k+1} f\left(t_{j}, y_{j}\right).\]


\[b_{j, k+1}=\frac{h^{\alpha}}{\alpha}\left((k+1-j)^{\alpha}-(k-j)^{\alpha}\right).\]


>>> import brainpy as bp
>>> a, b, c = 10, 28, 8 / 3
>>> def lorenz(x, y, z, t):
>>>   dx = a * (y - x)
>>>   dy = x * (b - z) - y
>>>   dz = x * y - c * z
>>>   return dx, dy, dz
>>> duration = 30.
>>> dt = 0.005
>>> inits = [1., 0., 1.]
>>> f = bp.fde.CaputoEuler(lorenz, alpha=0.97, num_memory=int(duration / dt), inits=inits)
>>> runner = bp.integrators.IntegratorRunner(f, monitors=list('xyz'), dt=dt, inits=inits)
>>> import matplotlib.pyplot as plt
>>> plt.plot(runner.mon.x.flatten(), runner.mon.z.flatten())
  • f (callable) – The derivative function.

  • alpha (int, float, jnp.ndarray, bm.ndarray, sequence) – The fractional-order of the derivative function. Should be in the range of (0., 1.).

  • num_memory (int) – The total time step of the simulation.

  • inits (sequence) – A sequence of the initial values for variables.

  • dt (float, int) – The numerical precision.

  • name (str) – The integrator name.



Li, Changpin, and Fanhai Zeng. “The finite difference methods for fractional ordinary differential equations.” Numerical Functional Analysis and Optimization 34.2 (2013): 149-179.


Diethelm, Kai, Neville J. Ford, and Alan D. Freed. “Detailed error analysis for a fractional Adams method.” Numerical algorithms 36.1 (2004): 31-52.

__init__(f, alpha, num_memory, inits, dt=None, name=None, state_delays=None)[source]#


__init__(f, alpha, num_memory, inits[, dt, ...])

load_states(filename[, verbose])

Load the model states.

nodes([method, level, include_self])

Collect all children nodes.

register_implicit_nodes(*nodes, **named_nodes)

register_implicit_vars(*variables, ...)

save_states(filename[, variables])

Save the model states.


Set the integral function.

train_vars([method, level, include_self])

The shortcut for retrieving all trainable variables.

unique_name([name, type_])

Get the unique name for this object.

vars([method, level, include_self])

Collect all variables in this node and the children nodes.



All arguments when calling the numer integrator of the differential equation.


The numerical integration precision.


The integral function.


Name of the model.


The parameters defined in the differential equation.


State delays.


The variables defined in the differential equation.