pub fn try_simpson<E>(
f: impl Fn(f64) -> Result<f64, E>,
a: f64,
b: f64,
n: usize,
) -> Result<f64, E>Expand description
simpson of a fallible integrand: the first error stops the quadrature.
§Errors
The first error of f.
§Examples
use comnum_math::try_simpson;
let v: Result<f64, String> = try_simpson(|t| Ok(t * t), 0.0, 3.0, 4);
assert!((v.unwrap() - 9.0).abs() < 1e-14);
let e: Result<f64, String> = try_simpson(|t| if t > 1.0 { Err("beyond 1".into()) } else { Ok(t) }, 0.0, 2.0, 4);
assert!(e.is_err());