CaputoEuler

Contents

CaputoEuler#

class brainpy.integrators.fde.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).\]

where

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

Examples

>>> 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)
>>> runner.run(duration)
>>>
>>> import matplotlib.pyplot as plt
>>> plt.plot(runner.mon.x.flatten(), runner.mon.z.flatten())
>>> plt.show()
Parameters:
  • 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.

References