#quadrature #integral

quad_gk

Pure rust numerical integration library based on Gauss Kronrod quadrature rule

3 releases (1 stable)

1.0.0 Apr 28, 2024
0.1.1 Apr 6, 2024
0.1.0 Apr 6, 2024

#387 in Math

Download history 30/week @ 2024-07-29 35/week @ 2024-09-23

161 downloads per month

MIT license

58KB
2.5K SLoC

quad_gk

Fast and precise numerical integration library based on Gauss Kronrod quadrature rule.

Basic usage

use std::sync::Arc;

use quad_gk::*;

let integral: Integral = quad_gk!(
    Arc::new(|x: f64| x.sin() * (-x).exp()),
    0.0..100.0,
);

// estimated relative error in numerical integration is smaller than 1e-6 by default.
assert!(integral.is_ok(1e-6))

More precise calculation

use std::sync::Arc;

use quad_gk::*;

let integral: Integral = quad_gk!(
    Arc::new(|x: f64| x.sin() * (-x).exp()),
    0.0..100.0,
    rel_tol=1e-14,
    max_interval_count=1_000_000,
    coef=GK91,
);

// estimated relative error in numerical integration is smaller than 1e-14!
assert!(integral.is_ok(1e-14))

lib.rs:

quad_gk

Fast and precise numerical integration library based on Gauss Kronrod quadrature rule.

Basic usage

use std::sync::Arc;

use quad_gk::*;

let integral: Integral = quad_gk!(
Arc::new(|x: f64| x.sin() * (-x).exp()),
0.0..100.0,
);

// estimated relative error in numerical integration is smaller than 1e-6 by default.
assert!(integral.is_ok(1e-6))

More precise calculation

use std::sync::Arc;

use quad_gk::*;

let integral: Integral = quad_gk!(
Arc::new(|x: f64| x.sin() * (-x).exp()),
0.0..100.0,
rel_tol=1e-14,
max_interval_count=1_000_000,
coef=GK91,
);

// estimated relative error in numerical integration is smaller than 1e-14!
assert!(integral.is_ok(1e-14))

Dependencies

~1.5MB
~25K SLoC