ode_midpoint_step

ode_midpoint_step#

class braintools.quad.ode_midpoint_step(f, y, t, *args, **kwargs)#

Second-order Runge-Kutta (midpoint) step for ODEs.

Uses the explicit midpoint variant:

  • k1 = f(y, t)

  • k2 = f(y + 0.5*dt*k1, t + 0.5*dt)

  • y_{n+1} = y + dt*k2

Parameters:
  • f (Callable[[PyTree, float | Quantity, ...], PyTree]) – Right-hand side function f(y, t, *args) -> PyTree.

  • y (PyTree) – Current state at time t.

  • t (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Current time.

  • *args – Additional positional arguments forwarded to f.

Returns:

The updated state after one RK2-midpoint step.

Return type:

PyTree

See also

ode_rk2_step

Heun/modified Euler variant of RK2.

ode_rk4_step

Classical fourth-order Runge-Kutta.