Context
rk4_step uses fixed step size. Stiff systems and rapidly-changing dynamics need adaptive step-size control to maintain accuracy without wasting evaluations.
Proposed API
pub fn rk45_adaptive(
state: f32, t0: f32, t_end: f32, dt_initial: f32, tol: f32,
f: impl Fn(f32, f32) -> f32,
) -> (f32, f32, u32) // (final_state, final_time, steps_taken)
Dormand-Prince method with embedded 4th/5th order error estimate. Step size adjusted by dt *= 0.9 * (tol/error)^0.2.
Thesis alignment
- Pure:
(state, t0, t_end, dt, tol, f) -> (state, t, steps)
- ADVANCE-EXCEPTION: while loop bounded by max_steps
- No
&mut in public API
Tests needed
- dy/dt = -y gives exp(-t) within tolerance
- Oscillator energy conservation
- Step count is reasonable (fewer than fixed-step for same accuracy)
- Deterministic
Context
rk4_stepuses fixed step size. Stiff systems and rapidly-changing dynamics need adaptive step-size control to maintain accuracy without wasting evaluations.Proposed API
Dormand-Prince method with embedded 4th/5th order error estimate. Step size adjusted by
dt *= 0.9 * (tol/error)^0.2.Thesis alignment
(state, t0, t_end, dt, tol, f) -> (state, t, steps)&mutin public APITests needed