rkf45_method

Function rkf45_method 

Source
pub fn rkf45_method<F>(
    f: F,
    x0: f64,
    y0: f64,
    x_end: f64,
    initial_step: f64,
    config: &AdaptiveConfig,
) -> Vec<(f64, f64)>
where F: Fn(f64, f64) -> f64,
Expand description

Solves a first-order ODE using Runge-Kutta-Fehlberg method with adaptive step size

§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
  • initial_step - Initial step size
  • config - Configuration for adaptive stepping

§Returns

Vector of (x, y) solution points with adaptively chosen steps

§Examples

use mathhook_core::calculus::ode::numerical::adaptive::{rkf45_method, AdaptiveConfig};

let solution = rkf45_method(
    |_x, y| y,
    0.0,
    1.0,
    1.0,
    0.1,
    &AdaptiveConfig::default()
);

assert!(solution.len() > 0);
let (_, y_final) = solution.last().unwrap();
let expected = 1.0_f64.exp();
assert!((y_final - expected).abs() < 1e-5);