cdawson, dawson - Dawson's integral
#include <cerf.h>
double complex cdawson ( double complex z );
double dawson ( 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 cdawson returns Dawson's integral D(z) = exp(-z^2) integral from 0 to z exp(t^2) dt = sqrt(pi)/2 * exp(-z^2) * erfi(z).
For function dawson takes a real argument x, and returns the real result D(x).
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.
dawson(x) = sqrt(pi)/2 Im w(x) inherits the accuracy of im_w_of_x(3): its relative error was found below 2.7 eps at random points with |x| up to 1e12.
cdawson is computed from w_of_z(3) as D(z) = -i sqrt(pi)/2 (w(z) - exp(-z^2)), and the exponent -z^2 = (y-x)(x+y) - 2ixy is carried as an unevaluated sum of two doubles, so that the factor is obtained to about 4 eps whatever |z| (Wuttke, see REFERENCES). At 20000 random points where the exponential neither over- nor underflows, |z| reaching 1e8, the relative error of the modulus stays below 6.9 eps. Before libcerf-3.7 the exponent was rounded into a single double, and the error grew in proportion to |z|^2, reaching 1080 eps at |z| = 26 and leaving no correct digit at all where x^2-y^2 stays small up to |z| = 1e8. One further improvement is available and not yet implemented: in the sector about the real axis where exp(-z^2) is negligible against w(z), evaluating the two terms separately, which leaves 7.5 eps for the modulus and 7.8 eps for the components.
Close to the real axis and inside |z| < 7, cdawson inherits the expansion that w_of_z(3) uses for Re w there, and its relative error is correspondingly smaller: cdawson(-5, 0.00051), for instance, falls from 1300 to 0.1 eps. Near the zeros of D(z), which are those of erfi, the first of which lie at z = +-1.8809 +- 1.4506i, cancellation amplifies the relative error without bound. Close to the origin, for 0.005 < |z| < 0.1 off the coordinate axes, where the Maclaurin series is not used, up to about 320 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 computation of D(z) is based on Faddeeva's function w_of_z(3); to compute D(x), the imaginary part im_w_of_x(3) is used.
Other complex error functions: w_of_z(3), voigt(3), cerf(3), erfcx(3), erfi(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.