pub mod gaussian;
pub mod romberg;
pub mod simpson;
pub use gaussian::GaussianQuadrature;
pub use romberg::RombergIntegration;
pub use simpson::AdaptiveSimpson;
use crate::error::MathError;
#[derive(Debug, Clone)]
pub struct IntegrationConfig {
pub tolerance: f64,
pub max_iterations: usize,
pub min_subdivisions: usize,
}
impl Default for IntegrationConfig {
fn default() -> Self {
Self {
tolerance: 1e-10,
max_iterations: 1000,
min_subdivisions: 1,
}
}
}
#[derive(Debug, Clone)]
pub struct IntegrationResult {
pub value: f64,
pub error_estimate: f64,
pub iterations: usize,
pub subdivisions: usize,
}
pub trait NumericalIntegrator {
fn integrate<F>(
&self,
f: F,
a: f64,
b: f64,
config: &IntegrationConfig,
) -> Result<IntegrationResult, MathError>
where
F: Fn(f64) -> f64;
}