User Tools

Site Tools


libcerf

This is the home page of libcerf, a self-contained numeric library that provides an efficient and accurate implementation of complex error functions, along with Dawson, Faddeeva, and Voigt functions.

Introduction

On current GNU/Linux systems, the man page complex(7) has a “see also” section that lists complex mathematical functions like cabs(3), cacos(3), and so on. Among them, there is a complex error function. However, its manual page cerf(3) describes the functions cerf and cerfc as “unimplemented” and “reserved for future use”. The present library libcerf provides the missing implementation, along with a related functions. It comes with a set of man pages, including a page cerf(3) that overwrites the standard one.

User Documentation

Synopsis

In the following, “complex” stands for the C99 data type “double _Complex”:

  • complex cerf (complex): The complex error function erf(z).
  • complex cerfc (complex): The complex complementary error function erfc(z) = 1 - erf(z).
  • complex cerfcx (complex z): The underflow-compensating function erfcx(z) = exp(z^2) erfc(z).
  • double erfcx (double x): The same for real x.
  • complex cerfi (complex z): The imaginary error function erfi(z) = -i erf(iz).
  • double erfi (double x): The same for real x.
  • complex w_of_z (complex z): Faddeeva's scaled complex error function w(z) = exp(-z^2) erfc(-iz).
  • double im_w_of_x (double x): The same for real x, returning the purely imaginary result as a real number.
  • complex cdawson (complex z): Dawson's integral D(z) = sqrt(pi)/2 * exp(-z^2) * erfi(z).
  • double dawson (double x): The same for real x.
  • double voigt (double x, double sigma, double gamma): The convolution of a Gaussian and a Lorentzian.

Language bindings

The C library libcerf can be wrapped for use with other programming languages. Such language bindings are added to the libcerf package as contributed by their authors.

The following bindings are available:

  • fortran, by Antonio Cervellino (Paul Scherrer Institut)

Further contributions will be highly welcome.

Accuracy

By construction, it is expected that the relative accuracy is generally better than 1E-13. This has been confirmed by comparison with high-precision Maple computations and with a long double computation using Fourier transform representation and double-exponential transform.

Copyright (C) Steven G. Johnson, Massachusetts Institute of Technology, 2012; Joachim Wuttke, Forschungszentrum Jülich, 2013.

License: MIT License

When using libcerf in scientific work, please cite as follows:

Please send bug reports to the authors.

Further references

Most function evaluations in this library rely on Faddeeva's function w(z).

This function has been reimplemented from scratch by Steven G. Johnson; project web site http://ab-initio.mit.edu/Faddeeva. The implementation partly relies on algorithms from the following publications:

  • Walter Gautschi, Efficient computation of the complex error function, SIAM J. Numer. Anal. 7, 187 (1970).
  • G. P. M. Poppe and C. M. J. Wijers, More efficient computation of the complex error function, ACM Trans. Math. Soft. 16, 38 (1990).
  • Mofreh R. Zaghloul and Ahmed N. Ali, Algorithm 916: Computing the Faddeyeva and Voigt Functions, ACM Trans. Math. Soft. 38, 15 (2011).

Installation

From source

Download location: http://apps.jcns.fz-juelich.de/src/libcerf/

The source package comes with build scripts generated with GNU autotools, to be run with the usual commands ./configure, make, sudo make install. To test, run the programs in directory test/.

The library has been developed using gcc-4.7. Reports about successful compilation with older versions of gcc would be welcome. For correct support of complex numbers it seems that at least gcc-4.3 is required. Compilation with gcc-4.2 works after removing of the “-Werror” flag from configure.

Binary packages