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 forward Euler method.

§Arguments

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

§Returns

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

§Panics

Panics if n is zero.