mathhook_core/calculus/integrals/
numerical.rs1pub mod gaussian;
7pub mod romberg;
8pub mod simpson;
9
10pub use gaussian::GaussianQuadrature;
11pub use romberg::RombergIntegration;
12pub use simpson::AdaptiveSimpson;
13
14use crate::error::MathError;
15
16#[derive(Debug, Clone)]
18pub struct IntegrationConfig {
19 pub tolerance: f64,
20 pub max_iterations: usize,
21 pub min_subdivisions: usize,
22}
23
24impl Default for IntegrationConfig {
25 fn default() -> Self {
26 Self {
27 tolerance: 1e-10,
28 max_iterations: 1000,
29 min_subdivisions: 1,
30 }
31 }
32}
33
34#[derive(Debug, Clone)]
36pub struct IntegrationResult {
37 pub value: f64,
38 pub error_estimate: f64,
39 pub iterations: usize,
40 pub subdivisions: usize,
41}
42
43pub trait NumericalIntegrator {
45 fn integrate<F>(
58 &self,
59 f: F,
60 a: f64,
61 b: f64,
62 config: &IntegrationConfig,
63 ) -> Result<IntegrationResult, MathError>
64 where
65 F: Fn(f64) -> f64;
66}