braincell.quad.ralston4_step#
- braincell.quad.ralston4_step(target, *args)[source]#
Advance one step with Ralston’s fourth-order Runge-Kutta method.
Ralston’s four-stage fourth-order RK method uses non-rational coefficients chosen to minimise the leading-order truncation error coefficient relative to classical RK4:
\[\begin{split}k_1 &= f(t_n, y_n), \\ k_2 &= f(t_n + 0.4\,\Delta t,\ y_n + 0.4\,\Delta t \, k_1), \\ k_3 &= f(t_n + 0.45573725\,\Delta t,\ y_n + 0.29697761\,\Delta t \, k_1 + 0.15875964\,\Delta t \, k_2), \\ k_4 &= f(t_n + \Delta t,\ y_n + 0.21810040\,\Delta t \, k_1 - 3.05096516\,\Delta t \, k_2 + 3.83286476\,\Delta t \, k_3), \\ y_{n+1} &= y_n + \Delta t \,\bigl( 0.17476028\, k_1 - 0.55148066\, k_2 + 1.20553560\, k_3 + 0.17118478\, k_4 \bigr).\end{split}\]Local truncation error is \(O(\Delta t^5)\); global error is \(O(\Delta t^4)\). The negative weight on \(k_2\) makes this scheme slightly more sensitive to floating-point cancellation than classical
rk4_step(), but the leading error constant is smaller.- 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
rk4_stepClassical fourth-order Runge-Kutta with rational weights.
Notes
The Butcher tableau is stored as
ralston4_tableau.References
Examples
>>> import brainstate >>> import brainunit as u >>> from braincell.quad import ralston4_step >>> with brainstate.environ.context(t=0. * u.ms, dt=0.01 * u.ms): ... ralston4_step(my_neuron)