Skip to main content

solve

Function solve 

Source
pub fn solve(
    f: &dyn Fn(f64, f64) -> f64,
    x0: f64,
    y0: f64,
    x_end: f64,
    n: usize,
) -> (Vec<f64>, Vec<f64>)
Expand description

Solve an IVP using the classical RK4 method.

§Arguments

  • f — Right-hand side dy/dx = f(x, y).
  • x0 — Initial independent variable.
  • y0 — Initial value.
  • x_end — Terminal value.
  • n — Number of steps (≥ 1).

§Returns

(xs, ys) — vectors of x and y at each step.