euler_method

Function euler_method 

Source
pub fn euler_method<F>(
    f: F,
    x0: f64,
    y0: f64,
    x_end: f64,
    step: f64,
) -> Vec<(f64, f64)>
where F: Fn(f64, 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 value
  • y0 - Initial y value
  • x_end - Final x value
  • step - 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));