ode_rk45_step#
- class braintools.quad.ode_rk45_step(f, y, t, *args, return_error=False, **kwargs)#
One step of the Cash-Karp embedded Runge-Kutta 4(5) method.
Computes a 5th-order solution and a 4th-order embedded solution using six stages. Optionally returns a PyTree error estimate
y5 - y4for adaptive step-size controllers.- Parameters:
f (
Callable[[PyTree,float|Quantity,...],PyTree]) – Right-hand side functionf(y, t, *args) -> PyTree.y (
PyTree) – Current state at timet.t (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Current time.*args – Additional positional arguments forwarded to
f.return_error (
bool) – If True, also return a PyTree error estimate(y5 - y4).
- Returns:
The updated state (5th-order). If
return_erroris True, returns(y_next, error_estimate)where both are PyTrees matchingy.- Return type:
PyTree or tuple
Notes
Butcher tableau (c, a, b5, b4): - c = [0, 1/5, 3/10, 3/5, 1, 7/8] - a21 = 1/5 - a31 = 3/40, a32 = 9/40 - a41 = 3/10, a42 = -9/10, a43 = 6/5 - a51 = -11/54, a52 = 5/2, a53 = -70/27, a54 = 35/27 - a61 = 1631/55296, a62 = 175/512, a63 = 575/13824, a64 = 44275/110592, a65 = 253/4096 - b5 = [37/378, 0, 250/621, 125/594, 0, 512/1771] - b4 = [2825/27648, 0, 18575/48384, 13525/55296, 277/14336, 1/4]