pub fn euler_method<F>(
f: F,
x0: f64,
y0: f64,
x_end: f64,
step: f64,
) -> Vec<(f64, f64)>Expand description
Solves a first-order ODE using forward Euler method
§Arguments
f- The derivative function f(x, y) where dy/dx = f(x, y)x0- Initial x valuey0- Initial y valuex_end- Final x valuestep- Step size h
§Returns
Vector of (x, y) solution points
§Examples
use mathhook_core::calculus::ode::numerical::euler::euler_method;
let solution = euler_method(
|x, _y| x,
0.0,
0.0,
1.0,
0.1
);
assert!(solution.len() > 0);
assert_eq!(solution[0], (0.0, 0.0));