pub fn erfc(x: f64) -> f64Expand description
Complementary error function $\operatorname{erfc}(x) = \frac{2}{\sqrt{\pi}} \int_{x}^{\infty} e^{-t^{2}}, dt$.
The rational Chebyshev approximations of Cody (1969), as in his CALERF (SPECFUN,
1990): $1 - x R_{1}(x^{2})$ for $|x| \le 0.46875$,
$e^{-x^{2}} R_{2}(x)$ up to 4 and $\frac{e^{-x^{2}}}{x} \left(\frac{1}{\sqrt{\pi}} +
\frac{1}{x^{2}} R_{3}(1/x^{2})\right)$ beyond, $e^{-x^{2}}$ computed in two factors so
that its rounding does not grow with $x^{2}$; $2 - \operatorname{erfc}(-x)$ for
$x < -0.46875$. Its relative error is below $10^{-15}$ wherever the result is a
normal number (against mpmath, the tail included: $\operatorname{erfc}(26) \approx
5.7 \cdot 10^{-296}$); it underflows to 0 beyond 27.3.
§Examples
use comnum_math::erfc;
assert!((erfc(1.0) / 0.157_299_207_050_285_13 - 1.0).abs() < 1e-15);
assert!((erfc(10.0) / 2.088_487_583_762_544_8e-45 - 1.0).abs() < 1e-15);§References
- W. J. Cody, “Rational Chebyshev approximations for the error function,” Math. Comp., 23(107), 631–637, 1969.
- W. J. Cody, “Algorithm 715: SPECFUN — a portable FORTRAN package of special function routines and test drivers,” ACM Trans. Math. Softw., 19(1), 22–32, 1993.