use russell_lab::{vec_approx_eq, StrError, Vector}; use russell_ode::prelude::*; fn main() -> Result<(), StrError> { // ODE system let ndim = 1; let system = System::new(ndim, |f, x, y, _args: &mut NoArgs| { f[0] = x + y[0]; Ok(()) }); // solver let params = Params::new(Method::DoPri8); let mut solver = OdeSolver::new(params, system)?; // initial values let x = 0.0; let mut y = Vector::from(&[0.0]); // solve from x = 0 to x = 1 let x1 = 1.0; let mut args = 0; solver.solve(&mut y, x, x1, None, &mut args)?; println!("y =\n{}", y); // check the results let y_ana = Vector::from(&[f64::exp(x1) - x1 - 1.0]); vec_approx_eq(&y, &y_ana, 1e-7); // print stats println!("{}", solver.stats()); Ok(()) }