# Faddeeva function

The Faddeeva function or Kramp function is a scaled complex complementary error function,
    $w(z):=e^{-z^{2}}\operatorname {erfc} (-iz)=\operatorname {erfcx} (-iz)=e^{-z^{2}}\left(1+{\frac {2i}{\sqrt {\pi }}}\int _{0}^{z}e^{t^{2}}{\text{d}}t\right).$
It is related to the Fresnel integral, to Dawson's integral, and to the Voigt function.
The function arises in various physical problems, typically relating to electromagnetic responses in complicated media.
* problems involving small-amplitude waves propagating through Maxwellian plasmas, and in particular appears in the plasma's permittivity from which dispersion relations are derived, hence it is sometimes referred to as the plasma dispersion function (although this name is sometimes used instead for the rescaled function Z(z) = i√π w(z) defined by Fried and Conte, 1961).
* the infrared permittivity functions of amorphous oxides have resonances (due to phonons) that are sometimes too complicated to fit using simple harmonic oscillators. The Brendel–Bormann oscillator model uses an infinite superposition of oscillators having slightly different frequencies, with a Gaussian distribution. The integrated response can be written in terms of the Faddeeva function.
* the Faddeeva function is also used in the analysis of electromagnetic waves of the type used in AM radio. Groundwaves are vertically polarised waves propagating over a lossy ground with finite resistivity and permittivity.
* the Faddeeva function also describes the changes of the neutron cross sections of materials as temperature is varied.

## Properties
### Real and imaginary parts

The decomposition into real and imaginary parts is usually written
    $w(x+iy)=V(x,y)+iL(x,y)$,
where V and L are called the real and imaginary Voigt functions, since V(x,y) is the Voigt profile (up to prefactors).

### Sign inversion

For sign-inverted arguments, the following both apply:
    $w(-z)=2e^{-z^{2}}-w(z)$
and
    $w(-z)=w\left(z^{*}\right)^{*}$
where * denotes complex conjugate.

### Relation to the complementary error function

The Faddeeva function evaluated on imaginary arguments equals the scaled complementary error function ($\mathrm {erfcx}$):
    $w(iz)=\mathrm {erfcx} (z)=e^{z^{2}}\mathrm {erfc} (z)$,
where erfc is the complementary error function. For large real x:
    $\mathrm {erfcx} (x)\approx {\frac {1}{{\sqrt {\pi }}x}}$

### Derivative

In some applications, it is necessary to know not only the original values of the Faddeeva function, but also its derivative (e.g. in Non-linear least squares regression in spectroscopy). Its derivative is given by:
    ${\frac {dw\left(z\right)}{dz}}={\frac {2i}{\sqrt {\pi }}}-2\cdot z\cdot w\left(z\right)$
This expression can also be broken down further in terms of changes in the real and imaginary part of the Faddeeva function $\Re \left(w\left(z\right)\right)=\Re _{w}$ and $\Im \left(w\left(z\right)\right)=\Im _{w}$. Basically, this requires knowledge about the real and imaginary part of the product $z\cdot w\left(z\right)$. Making use of the above definition $z=x+iy$, the derivative can therefore be split into partial derivatives with respect to $x$ and $y$ as follows:
    ${\frac {d\Re _{w}}{dx}}=2\cdot \left(y\cdot \Im _{w}-x\cdot \Re _{w}\right)={\frac {d\Im _{w}}{dy}}$ and ${\frac {d\Re _{w}}{dy}}=-2\cdot \left({\frac {1}{\sqrt {\pi }}}-x\cdot \Im _{w}-y\cdot \Re _{w}\right)=-{\frac {d\Im _{w}}{dx}}$
    ${\frac {d\Im _{w}}{dx}}=2\cdot \left({\frac {1}{\sqrt {\pi }}}-x\cdot \Im _{w}-y\cdot \Re _{w}\right)=-{\frac {d\Re _{w}}{dy}}$ and ${\frac {d\Im _{w}}{dy}}=2\cdot \left(y\cdot \Im _{w}-x\cdot \Re _{w}\right)={\frac {d\Re _{w}}{dx}}$
A practical example for the use of these partial derivatives can be found here.

## Integral representation

The Faddeeva function occurs as
    $w(z)={\frac {i}{\pi }}\int _{-\infty }^{\infty }{\frac {e^{-t^{2}}}{z-t}}\,\mathrm {d} t={\frac {2iz}{\pi }}\int _{0}^{\infty }{\frac {e^{-t^{2}}}{z^{2}-t^{2}}}\,\mathrm {d} t,\qquad \operatorname {Im} z>0$
meaning that it is a convolution of a Gaussian with a simple pole.

## History

The function was tabulated by Vera Faddeeva and N. N. Terentyev in 1954. It appears as nameless function w(z) in Abramowitz and Stegun (1964), formula 7.1.3. The name Faddeeva function was apparently introduced by G. P. M. Poppe and C. M. J. Wijers in 1990; previously, it was known as Kramp's function (probably after Christian Kramp).
Early implementations used methods by Walter Gautschi (1969–70; ACM Algorithm 363) or by J. Humlicek (1982). A more efficient algorithm was proposed by Poppe and Wijers (1990; ACM Algorithm 680). J.A.C. Weideman (1994) proposed a particularly short algorithm that takes no more than eight lines of MATLAB code. Zaghloul and Ali pointed out deficiencies of previous algorithms and proposed a new one (2011; ACM Algorithm 916). Another algorithm has been proposed by M. Abrarov and B.M. Quine (2011/2012).

## Implementations

Two software implementations, which are free for non-commercial use only, were published in ACM Transactions on Mathematical Software (TOMS) as Algorithm 680 (in Fortran, later translated into C) and Algorithm 916 by Zaghloul and Ali (in MATLAB).
A free and open source C or C++ implementation derived from a combination of Algorithm 680 and Algorithm 916 (using different algorithms for different z) is also available under the MIT License, and is maintained as a library package libcerf. This implementation is also available as a plug-in for Matlab, GNU Octave, and in Python via Scipy as scipy.special.wofz (which was originally the TOMS 680 code, but was replaced due to copyright concerns).
For fast but still accurate calculation of plasma dispersion function $Z(z)$, the J-pole Pade approximation is found to be useful, i.e.,
    $Z(z)=\sum _{j=1}^{J}{\frac {b_{j}}{z-c_{j}}}.$
For J=8, one can use b1= -0.017340112270401 - 0.046306439626294i; b2= -0.739917811220052 + 0.839518284620274i; b3= 5.840632105105495 + 0.953602751322040i; b4= -5.583374181615043 -11.208550459628098i; c1= 2.237687725134293 - 1.625941024120362i; c2= 1.465234091939142 - 1.789620299603315i; c3= 0.839253966367922 - 1.891995211531426i; c4= 0.273936218055381 - 1.941787037576095i; b(5:8)=(b(1:4))*; c(5:8)=-(c(1:4))*,
where * denotes complex conjugate. The above approximation is valid for the upper plane. For $z$ weakly close to the real axis, i.e., $Im(z)$ not far from the real axis of the lower plane, the above approximation is also valid. For accurate calculation of $Im(z)<0$, one can use
    $Z(z)=[Z(z^{*})]^{*}+2i{\sqrt {\pi }}\exp[-z^{2}].$
A coding of the above J-pole approach and comparison with an accurate plasma dispersion function can be found. Comphensive coefficients to rapid computation of the plasma dispersion function with rational and multi-pole approximation are also available.