[−][src]Function peroxide::numerical::ode::solve
pub fn solve<F, T>(
f: F,
init_value: Vec<f64>,
param_range: (T, T),
step: f64,
method: ODEMethod
) -> Matrix where
F: Fn(Dual, Vec<Dual>) -> Vec<Dual> + Copy,
T: Into<f64> + Copy,
ODE Solver
Parameters
f = f(t, y)
init_value = y_start
param_range = (t_start, t_end)
Type
solve: (F, Vec<f64>, (T, T), f64, ODEMethod) -> Matrix where Fn(Dual, Vec<Dual>) -> Vec<Dual> + Copy, T: Into<f64> + Copy
Methods
RK4
: Explicit Runge-Kutta 4th orderBDF1
: Backward Differentiation Formula 1st order (Backward Euler)GL4
: Gauss-Legendre 4th order
Examples
extern crate peroxide; use peroxide::*; let init_val = c!(2, 1); let result = solve(lotka_volterra, init_val, (0, 10), 1e-3, RK4); result.print(); fn lotka_volterra(t: Dual, xs: Vec<Dual>) -> Vec<Dual> { let a = 4.; let c = 1.; let x = xs[0]; let y = xs[1]; vec![ a * (x - x*y), -c * (y - x*y) ] }