differential_equations/lib.rs
1//! # differential-equations
2//!
3//! A Rust library for solving various types of differential equations.
4//!
5//! [](https://github.com/Ryan-D-Gast/differential-equations)
6//! [](https://docs.rs/differential-equations)
7//!
8//! ## Overview
9//!
10//! This library provides numerical solvers for different classes of differential equations:
11//!
12//! - **[Ordinary Differential Equations (ODE)](crate::ode)**: Stable
13//! - Initial value problems (IVP)
14//! - Fixed and adaptive step methods
15//! - Event detection
16//! - Customizable output control
17//!
18//! ## Feature Flags
19//!
20//! - `polars`: Enable converting Solution to Polars DataFrame using `Solution.to_polars()`
21//!
22//! ## Example (ODE)
23//!
24//!```rust
25//! use differential_equations::ode::*;
26//! use nalgebra::{SVector, vector};
27//!
28//! pub struct LinearEquation {
29//! pub a: f64,
30//! pub b: f64,
31//! }
32//!
33//! impl ODE<f64, 1, 1> for LinearEquation {
34//! fn diff(&self, _t: f64, y: &SVector<f64, 1>, dydt: &mut SVector<f64, 1>) {
35//! dydt[0] = self.a + self.b * y[0];
36//! }
37//! }
38//!
39//! fn main() {
40//! let system = LinearEquation { a: 1.0, b: 2.0 };
41//! let t0 = 0.0;
42//! let tf = 1.0;
43//! let y0 = vector![1.0];
44//! let ivp = IVP::new(system, t0, tf, y0);
45//! let mut solver = DOP853::new().rtol(1e-8).atol(1e-6);
46//! let solution = match ivp.solve(&mut solver) {
47//! Ok(sol) => sol,
48//! Err(e) => panic!("Error: {:?}", e),
49//! };
50//!
51//! for (t, y) in solution.iter() {
52//! println!("t: {:.4}, y: {:.4}", t, y[0]);
53//! }
54//! }
55//!```
56//!
57//! # License
58//!
59//! ```text
60//! Copyright 2025 Ryan D. Gast
61//!
62//! Licensed under the Apache License, Version 2.0 (the "License");
63//! you may not use this file except in compliance with the License.
64//! You may obtain a copy of the License at
65//!
66//! http://www.apache.org/licenses/LICENSE-2.0
67//!
68//! Unless required by applicable law or agreed to in writing, software
69//! distributed under the License is distributed on an "AS IS" BASIS,
70//! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
71//! See the License for the specific language governing permissions and
72//! limitations under the License.
73//! ```
74
75// Re-export of nalgebra types for macros and convenience
76pub use nalgebra::{SMatrix, matrix, SVector, vector};
77
78// Traits for Floating Point Types
79pub mod traits;
80
81// Interpolation Functions
82pub mod interpolate;
83
84// Ordinary Differential Equations (ODE) Module
85pub mod ode;