cerfcx3
Underflow-compensated complementary error function
Usage
double complex
cerfcx
(
double
complex
z
);
double erfcx
(
double
x
);
Overview
The function cerfcx is an underflow-compensated variant of the complex error function: erfcx(z) = exp(z^2) erfc(z). It is a thin wrapper around Faddeeva's function w_of_z(3), which it calls as erfcx(z) = w(iz).
The function erfcx takes a real argument and returns a real result. Its implementation is self-contained.
Accuracy
Errors are given in units of eps = 2^-53 = 1.1e-16, as relative deviations from high-precision reference values; for complex results, of the modulus.
For 0.125 <= x < 12, erfcx uses a piecewise Chebyshev approximation generated by ppapp, whose error analysis (Wuttke and Kleinsorge, ACM Trans. Math. Softw. 52, 13, 2026) bounds the relative error by 2.1 eps. For 0 <= x < 0.125 the Maclaurin series is used and for x >= 12 the asymptotic expansion; for neither has a complete bound been written down yet, although both series alternate with decreasing terms, so that their truncation error is bounded by the first term omitted. The relative error was found below 2.1 eps. For x < 0, erfcx(x) = 2 exp(x^2) - erfcx(-x) is dominated by the exponential, whose exponent x^2 is carried as an unevaluated sum of two doubles; the relative error was found below 2.6 eps. For x < -26.63 the result overflows.
cerfcx(z) = w(iz) inherits the accuracy of w_of_z(3), the rotation by a right angle being exact. For Re z >= 0, the relative error of the modulus is bounded by 3 eps for |z| < 7 and by 5.2 eps for |z| >= 7. For Re z < 0, erfcx(z) = 2 exp(z^2) - erfcx(-z) is used, with the exponent carried as an unevaluated sum of two doubles; the two terms may cancel, and the error is not controlled. Near the zeros of erfcx, the first pair of which lies at z = -1.3548 +- 1.9915i, the relative error is unbounded. An improved implementation is under preparation.
References
Joachim Wuttke, "libcerf, complex error function and related functions reimplemented with relative accuracy guarantees" (unpublished manuscript, available upon request) documents the algorithms of this library and derives their error bounds.
Authors, revision history, reference
Until libcerf-2.4, this was mostly a wrapper of MIT Faddeeva code by Steven G. Johnson.
In libcerf-2.5 of April 2025, the real function erfcx was reimplemented by Joachim Wuttke:
- •
-
for large |x|, using asymptotic expansions;
- •
-
for an expanded small |x| range, using Maclaurin series as before;
- •
-
for intermediate |x|, using piecewise Chebyshev approximation (Wuttke & Kleinsorge, ACM Trans. Math. Softw. 52, 13 (2026), doi:10.1145/3805698).
Contact
Please report bugs to the maintainer:
Joachim Wuttke <[email protected]>
Copying
Copyright (c) 2025 Forschungszentrum Juelich GmbH
Software: MIT License.
This documentation: Creative Commons Attribution Share Alike.
History
- Arch Linux 2026-11-01: the text shown here
- Debian 13 (Trixie)
- Debian 12 (Bookworm) to Debian 8 (Jessie)