pub fn ode_euler<F>(
f: F,
initial: (f64, f64),
x_end: f64,
steps: usize,
) -> Vec<(f64, f64)>Expand description
Numerical solution to ODE using Euler’s method
§Arguments
f- Differential equation dy/dx = f(x, y)initial- Initial condition (x₀, y₀)x_end- End pointsteps- Number of steps
§Example
use dodecet_encoder::calculus;
// dy/dx = y, y(0) = 1
let f = |x: f64, y: f64| y;
let solution = calculus::ode_euler(&f, (0.0, 1.0), 1.0, 100);
// At x=1, y≈e=2.718
assert!((solution.last().unwrap().1 - 2.718).abs() < 0.1);