braincell.quad.heun2_step#
- braincell.quad.heun2_step(target, *args)[source]#
Advance one step with Heun’s second-order Runge-Kutta method.
Heun’s method (also known as the explicit trapezoidal rule or improved Euler) is a two-stage, second-order explicit scheme:
\[\begin{split}k_1 &= f(t_n, y_n), \\ k_2 &= f\!\left(t_n + \Delta t,\, y_n + \Delta t \, k_1\right), \\ y_{n+1} &= y_n + \tfrac{\Delta t}{2}\left(k_1 + k_2\right).\end{split}\]Local truncation error is \(O(\Delta t^3)\); global error is \(O(\Delta t^2)\).
- Parameters:
target (
DiffEqModule) – Differential-equation module to advance.*args – Extra positional arguments forwarded to
target’s integration hooks.
- Returns:
Updates target’s state in place.
- Return type:
None
See also
Notes
Butcher tableau (
heun2_tableau):\[\begin{split}\begin{array}{c|cc} 0 & 0 & 0 \\ 1 & 1 & 0 \\ \hline & \tfrac{1}{2} & \tfrac{1}{2} \end{array}\end{split}\]Examples
>>> import brainstate >>> import brainunit as u >>> from braincell.quad import heun2_step >>> with brainstate.environ.context(t=0. * u.ms, dt=0.01 * u.ms): ... heun2_step(my_neuron)