Skip to main content

erf_precise

Function erf_precise 

Source
pub fn erf_precise(x: f64) -> f64
Expand description

High-accuracy error function, accurate to near f64 machine precision.

Use this instead of erf wherever the result feeds a numerical-parity gate. erf (Abramowitz & Stegun 7.1.26) is only accurate to 1.5e-7 absolute.

ยงExamples

use batuta_common::math::erf_precise;
assert!((erf_precise(1.0) - 0.842_700_792_949_714_9).abs() < 1e-15);
assert!((erf_precise(-1.0) + 0.842_700_792_949_714_9).abs() < 1e-15);
assert_eq!(erf_precise(0.0), 0.0);