cerfi, erfi - imaginary error function
#include <cerf.h>
double complex cerfi ( double complex z );
double erfi ( double x );
The data type double complex is defined in the header <complex.h>, which C99 introduced. Since C11 it is optional: an implementation may define __STDC_NO_COMPLEX__ and then provide neither the header nor the type, and Microsoft's C compiler does not support the arithmetic operators for it. As a fallback, use the C++ variant of this library, libcerfcpp, in which double complex is replaced by std::complex<double> from the header <complex>.
The function cerfi returns an error function rotated in the complex plane, erfi(z) = -i erf(iz).
The function erfi takes a real argument and returns a real result.
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.
erfi(x) = exp(x^2) Im w(x) is computed from im_w_of_x(3). The exponent x^2 is carried as an unevaluated sum of two doubles, so that the relative error no longer grows with x: it was found below 4.7 eps at 2000 random points with 0.2 < x < 26.3. Before libcerf-3.7 the square was rounded into a single double, and the error grew like x^2 eps, reaching 510 eps at x = 26.1. The exponential alone overflows from |x| = 26.6417 on; since Im w(x) < 1/(sqrt(pi) x) brings the product back into range, a constant is split off the exponent there, so that the full range of erfi is available and +-Inf is returned only from |x| = 26.7140 on, where erfi itself exceeds the double format.
cerfi(z) = -i erf(iz) inherits the accuracy of cerf(3), the rotation by a right angle being exact: the relative error of the modulus stays below 5.5 eps, except near the zeros of erfi, the first of which lie at z = +-1.8809 +- 1.4506i, where it is amplified without bound, and close to the origin, for 0.01 < |z| < 0.1 off the coordinate axes, where up to about 120 eps were found.
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.
The implementation of cerfi and erfi is trivially based on the functions cerf(3) and im_w_of_x(3).
Other complex error functions in libcerf: dawson(3), erfcx(3), voigt(3), w_of_z(3).
The real error function comes with recent versions of glibc, as requested by the C99 standard: erf(3).
Homepage: https://jugit.fz-juelich.de/mlz/lib/cerf
Steven G. Johnson, Massachusetts Institute of Technology, wrote this function as part of the MIT Faddeeva package.
Joachim Wuttke, Forschungszentrum Juelich, reorganized the code into a library, and wrote this man page.
Please report bugs to the maintainer:
Joachim Wuttke <j.wuttke@fz-juelich.de>
Copyright (c) 2012 Massachusetts Institute of Technology
Copyright (c) 2013 Forschungszentrum Juelich GmbH
Software: MIT License.
This documentation: Creative Commons Attribution Share Alike.