CaputoL1Schema#

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

The L1 scheme method for the numerical approximation of the Caputo fractional-order derivative equations [3].

For the fractional order \(0<\alpha<1\), let the fractional derivative of variable \(x(t)\) be

\[\frac{d^{\alpha} x}{d t^{\alpha}}=F(x, t)\]

The Caputo definition of the fractional derivative for variable \(x\) is

\[\frac{d^{\alpha} x}{d t^{\alpha}}=\frac{1}{\Gamma(1-\alpha)} \int_{0}^{t} \frac{x^{\prime}(u)}{(t-u)^{\alpha}} d u\]

where \(\Gamma\) is the Gamma function.

The fractional-order derivative is capable of integrating the activity of the function over all past activities weighted by a function that follows a power-law. Using one of the numerical methods, the L1 scheme method [3], the numerical approximation of the fractional-order derivative of \(x\) is

\[\frac{d^{\alpha} \chi}{d t^{\alpha}} \approx \frac{(d t)^{-\alpha}}{\Gamma(2-\alpha)}\left[\sum_{k=0}^{N-1}\left[x\left(t_{k+1}\right)- \mathrm{x}\left(t_{k}\right)\right]\left[(N-k)^{1-\alpha}-(N-1-k)^{1-\alpha}\right]\right]\]

Therefore, the numerical solution of original system is given by

\[x\left(t_{N}\right) \approx d t^{\alpha} \Gamma(2-\alpha) F(x, t)+x\left(t_{N-1}\right)- \left[\sum_{k=0}^{N-2}\left[x\left(t_{k+1}\right)-x\left(t_{k}\right)\right]\left[(N-k)^{1-\alpha}-(N-1-k)^{1-\alpha}\right]\right]\]

Hence, the solution of the fractional-order derivative can be described as the difference between the Markov term and the memory trace. The Markov term weighted by the gamma function is

\[\text { Markov term }=d t^{\alpha} \Gamma(2-\alpha) F(x, t)+x\left(t_{N-1}\right)\]

The memory trace (\(x\)-memory trace since it is related to variable \(x\)) is

\[\text { Memory trace }=\sum_{k=0}^{N-2}\left[x\left(t_{k+1}\right)-x\left(t_{k}\right)\right]\left[(N-k)^{1-\alpha}-(N-(k+1))^{1-\alpha}\right]\]

The memory trace integrates all the past activity and captures the long-term history of the system. For \(\alpha=1\), the memory trace is 0 for any time \(t\). When the fractional order \(\alpha\) is decreased from 1, the memory trace non-linearly increases from 0, and its dynamics strongly depends on time. Thus, the fractional order dynamics strongly deviates from the first order dynamics.

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.CaputoL1Schema(lorenz, alpha=0.99, num_memory=int(duration / dt), inits=inits)
>>> runner = bp.IntegratorRunner(f, monitors=list('xz'), 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

hists(var=None, numpy=True)[source]#

Get the recorded history values.

reset(inits)[source]#

Reset function.