braincell.quad.ralston2_step#
- braincell.quad.ralston2_step(target, *args)[source]#
Advance one step with Ralston’s second-order Runge-Kutta method.
Ralston’s second-order method is the two-stage explicit Runge-Kutta scheme that minimises the leading-order truncation error coefficient among second-order RK2 variants:
\[\begin{split}k_1 &= f(t_n, y_n), \\ k_2 &= f\!\left(t_n + \tfrac{2}{3}\Delta t,\ y_n + \tfrac{2}{3}\Delta t \, k_1\right), \\ y_{n+1} &= y_n + \tfrac{\Delta t}{4}\left(k_1 + 3 k_2\right).\end{split}\]It is therefore identical to
rk2_step()and useful when an error-optimal RK2 scheme is desired without committing to higher cost. 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 (
ralston2_tableau):\[\begin{split}\begin{array}{c|cc} 0 & 0 & 0 \\ \tfrac{2}{3} & \tfrac{2}{3} & 0 \\ \hline & \tfrac{1}{4} & \tfrac{3}{4} \end{array}\end{split}\]References
Examples
>>> import brainstate >>> import brainunit as u >>> from braincell.quad import ralston2_step >>> with brainstate.environ.context(t=0. * u.ms, dt=0.01 * u.ms): ... ralston2_step(my_neuron)