voigt - Voigt's function, convolution of Gaussian and Lorentzian
#include <cerf.h>
double voigt ( double x, double sigma, double gamma );
The function voigt returns Voigt's convolution
voigt(x,sigma,gamma) = integral G(t,sigma) L(x-t,gamma) dt
of a Gaussian
G(x,sigma) = 1/sqrt(2*pi)/|sigma| * exp(-x^2/2/sigma^2)
and a Lorentzian
L(x,gamma) = |gamma| / pi / ( x^2 + gamma^2 ),
with the integral extending from -infinity to +infinity.
If sigma=0, L(x,gamma) is returned. Conversely, if gamma=0, G(x,sigma) is returned.
If sigma=gamma=0, the return value is Inf for x=0, and 0 for all other x. It is advisable to test input arguments to exclude this irregular case.
Errors are given in units of eps = 2^-53 = 1.1e-16, as relative deviations from high-precision reference values.
voigt is computed as Re w(z) / (sqrt(2 pi) sigma) from w_of_z(3), which controls the relative error of the modulus |w|, but not of its real part separately. Around the line center, both are of the same order, and the relative error of voigt was found below 7 eps for |x| < 2 sigma and below 16 eps for |x| < 3 sigma, for gamma between 1e-10 and 1e3 sigma.
In the wings, |x| >> sigma, the Lorentzian tail dominates, and Re w is smaller than |w| by a factor of about gamma/|x|; the relative error of voigt grows by the inverse factor. For |x| < 10 sigma, where w_of_z computes Re w from an expansion about the real axis, the loss is bounded by that of the expansion, a few eps: 0.4 eps were found at x = 7.5 sigma, gamma = 1e-8 sigma, where before that expansion was introduced the error reached 7e8 eps, a relative error of 8e-8. For |x| > 10 sigma, where the asymptotic expansion of w is used, up to 1.5e4 eps at x = 10 sigma, and below 6 eps for 15 sigma < |x| < 100 sigma. For gamma < 1e-9 |x|, w is obtained from a first-order expansion around the real axis, and the relative error of voigt is about 2.5 (x/sigma)^2 eps.
What remains is not inherent in the problem. The profile is nowhere smaller than gamma / (pi (x^2 + gamma^2 + sigma^2)), a proven lower bound, so that a componentwise error bound for Re w would carry over to voigt and would hold at about 12 eps over the whole parameter range. What is needed for that is set out in the manuscript cited below.
Formula (7.4.13) in Abramowitz & Stegun (1964) relates Voigt's convolution integral to Faddeeva's function w_of_z, upon which this implementation is based:
voigt(x,sigma,gamma) = Re[w(z)] / sqrt(2*pi) / |sigma|
with
z = (x+i*|gamma|) / sqrt(2) / |sigma|.
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.
voigt_hwhm(3)
Related complex error functions: w_of_z(3), dawson(3), cerf(3), erfcx(3), erfi(3).
Homepage: https://jugit.fz-juelich.de/mlz/lib/cerf
Joachim Wuttke, Forschungszentrum Juelich.
Please report bugs to the maintainer:
Joachim Wuttke <j.wuttke@fz-juelich.de>
Copyright (c) 2013-2025 Forschungszentrum Juelich GmbH
Software: MIT License.
This documentation: Creative Commons Attribution Share Alike.