Skip to main content

numerics_ode/
lib.rs

1//! # numerics-ode
2//!
3//! Research-grade ordinary differential equation (ODE) solvers implemented in pure Rust
4//! with zero external dependencies.
5//!
6//! ## Solvers
7//!
8//! - **Euler** — First-order explicit method. Simple but only O(h) accurate.
9//! - **RK4** — Classical fourth-order Runge-Kutta. O(h⁴) global error.
10//! - **Adams-Bashforth** — Second-order two-step explicit multistep method. O(h²).
11//! - **Dormand-Prince** — Embedded RK4(5) with adaptive step-size control. O(h⁴/⁵).
12//!
13//! ## System support
14//!
15//! All solvers support both scalar ODEs (`dy/dx = f(x, y)` where `y: f64`)
16//! and systems of ODEs (`dy/dx = f(x, &y)` where `y: Vec<f64>`).
17//!
18//! ## Example
19//!
20//! ```
21//! use numerics_ode::rk4;
22//!
23//! let f = |_x: f64, y: f64| y; // dy/dx = y
24//! let (xs, ys) = rk4::solve(&f, 0.0, 1.0, 1.0, 100);
25//! assert!((ys[100] - (1.0_f64).exp()).abs() < 1e-8);
26//! ```
27
28pub mod euler;
29pub mod rk4;
30pub mod adams_bashforth;
31pub mod dormand_prince;
32pub mod system;
33
34pub use euler::solve as euler_solve;
35pub use rk4::solve as rk4_solve;
36pub use adams_bashforth::solve as adams_bashforth_solve;
37pub use dormand_prince::solve_adaptive as dormand_prince_solve;