numra_fde/lib.rs
1// Clippy: numerical code uses index-heavy loops and literals from references.
2#![allow(clippy::needless_range_loop)]
3
4//! FDE (Fractional Differential Equation) solvers for Numra.
5//!
6//! This crate provides methods for solving fractional differential equations
7//! using the Caputo derivative:
8//!
9//! ```text
10//! D^α y(t) = f(t, y), y(0) = y₀
11//! ```
12//!
13//! where D^α is the Caputo fractional derivative of order α ∈ (0, 1].
14//!
15//! # The Caputo Derivative
16//!
17//! The Caputo fractional derivative of order α is defined as:
18//!
19//! ```text
20//! D^α y(t) = (1/Γ(1-α)) ∫₀ᵗ (t-s)^(-α) y'(s) ds
21//! ```
22//!
23//! Key properties:
24//! - Reduces to ordinary derivative when α = 1
25//! - D^α c = 0 for constants (unlike Riemann-Liouville)
26//! - Has "memory" - depends on full history of y
27//!
28//! # Solvers
29//!
30//! - [`L1Solver`] - L1 scheme for Caputo derivative (order 2-α accuracy)
31//!
32//! # Example
33//!
34//! ```
35//! use numra_fde::{FdeSystem, L1Solver, FdeSolver, FdeOptions};
36//!
37//! // Fractional relaxation: D^α y = -λy, y(0) = 1
38//! struct FractionalRelaxation { lambda: f64 }
39//!
40//! impl FdeSystem<f64> for FractionalRelaxation {
41//! fn dim(&self) -> usize { 1 }
42//! fn alpha(&self) -> f64 { 0.5 } // Half-order derivative
43//! fn rhs(&self, _t: f64, y: &[f64], f: &mut [f64]) {
44//! f[0] = -self.lambda * y[0];
45//! }
46//! }
47//!
48//! let system = FractionalRelaxation { lambda: 1.0 };
49//! let opts = FdeOptions::default().dt(0.01);
50//! let result = L1Solver::solve(&system, 0.0, 1.0, &[1.0], &opts);
51//! ```
52//!
53//! Author: Moussa Leblouba
54//! Date: 2 February 2026
55//! Modified: 2 May 2026
56
57pub use numra_core::Scalar;
58
59mod caputo;
60mod l1_solver;
61mod system;
62
63pub use caputo::{caputo_weights, gamma, mittag_leffler, mittag_leffler_1};
64pub use l1_solver::L1Solver;
65pub use system::{FdeOptions, FdeResult, FdeSolver, FdeSystem};