---
name: "cerfc"
section: "3"
platform: "linux"
package: "libcerf"
version: "1:3.9-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/cerfc"
---

# cerfc(3)

complex error functions

## NAME

cerf, cerfc - complex error functions

## SYNOPSIS

**#include \<cerf.h**\>

**double complex cerf ( double complex z );**

**double complex cerfc ( double complex z );**

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\>.

## DESCRIPTION

The function **cerf** is the complex version of the error function: erf(z) = 2/sqrt(pi) \* integral from 0 to z of exp(-t\*t) dt.

The complementary complex error function **cerfc** is defined as erfc(z) = 1-cerf(z).

## ACCURACY

Errors are given in units of eps = 2^-53 = 1.1e-16, as relative deviations of the modulus from high-precision reference values.

Both functions are computed from Faddeeva's function [**w\_of\_z**(3)](/w_of_z/3.md) through the factor exp(-z^2), as erfc(z) = exp(-z^2) w(iz) and erf(z) = 1 - erfc(z), with the exponent -z^2 carried as an unevaluated sum of two doubles. Where exp(-z^2) overflows although the product with w does not, the modulus of the factor is taken in scaled form and the scale applied to the product, so that both functions cover their full range and return an infinity only where the value itself exceeds the double format.

The error is not controlled. For Re z \< 0, w(iz) is obtained by reflection, and cancellation must be expected (see [**w\_of\_z**(3)](/w_of_z/3.md)); near the zeros of erfc, the first of which lie at z = -1.3548 +- 1.9915i, the relative error of **cerfc** is unbounded. **cerf** shares the error of **cerfc** in absolute terms, so that its relative error is unbounded near the zeros of erf, the first of which lie at z = +-1.4506 +- 1.8809i, and reaches about 120 eps close to the origin, for 0.01 \< \|z\| \< 0.1 off the coordinate axes, where the Maclaurin series is not used.

## REFERENCES

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.

## SEE ALSO

The computations are based on Faddeeva's function **[w\_of\_z(3)](/w_of_z/3.md)**.

Other complex error functions in libcerf: [**w\_of\_z**(3)](/w_of_z/3.md), [**dawson**(3)](/dawson/3.md), [**voigt**(3)](/voigt/3.md), [**erfcx**(3)](/erfcx/3.md), [**erfi**(3)](/erfi/3.md).

The real error function comes with recent versions of glibc, as requested by the C99 standard: [**erf**(3)](/erf/3.md)

Homepage: https://jugit.fz-juelich.de/mlz/lib/cerf

## AUTHORS

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.

## CONTACT

Please report bugs to the maintainer:

Joachim Wuttke \<j.wuttke@fz-juelich.de\>

## COPYING

Copyright (c) 2012 Massachusetts Institute of Technology

Copyright (c) 2013 Forschungszentrum Juelich GmbH

Software: MIT License.

This documentation: Creative Commons Attribution Share Alike.
