Skip to main content

integrate

Function integrate 

Source
pub fn integrate<const N: usize, F>(
    y: &mut [f64; N],
    t: f64,
    dt: f64,
    h_max: f64,
    f: F,
) -> usize
where F: FnMut(f64, &[f64; N]) -> [f64; N],
Expand description

Integrate y' = f(t, y) from t to t + dt in equal RK4 substeps no longer than h_max, returning how many were taken (CORE-R37).

  • dt ≤ 0 or non-finite: nothing happens, f is never called, returns 0.
  • Steps: ceil(dt / h_max) (with a 1e-9 relative slack for exact multiples), at least 1 and at most MAX_STEPS.
  • h_max below MIN_STEP (including 0, negative, NaN) is raised to MIN_STEP; h_max = +∞ means a single step.

Substep times are computed as t + i·h, not accumulated, so they do not drift.