Error function
Template:Short description Script error: No such module "Unsubst". Script error: No such module "Distinguish". In mathematics, the error function (also called the Gauss error function), often denoted by , is the functionScript error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". Script error: No such module "Infobox".Script error: No such module "Check for unknown parameters".
The integral here is a complex contour integral which is path-independent because is holomorphic on the whole complex plane . In many applications, the function argument is a real number, in which case the function value is also real.
In some older texts,Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". the error function is defined without the factor of . This nonelementary integral is a sigmoid function that occurs often in probability, statistics, and partial differential equations.
In statistics, for non-negative real values of , the error function has the following interpretation: for a real random variable that is normally distributed with mean 0 and standard deviation , is the probability that falls in the range .
Two closely related functions are the complementary error function
and the imaginary error function
where is the imaginary unit.
Name
The name "error function" and its abbreviation were proposed by J. W. L. Glaisher in 1871 on account of its connection with "the theory of probability, and notably the theory of errors".Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". The complementary error function was also discussed by Glaisher in a separate publication in the same year.Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". For the "law of facility" of errors whose density is given by
(the normal distribution), Glaisher calculates the probability of an error lying between and as
Applications
When the results of a series of measurements are described by a normal distribution with standard deviation and expected value zero, then
is the probability that the error of a single measurement lies between and . This is useful, for example, in determining the bit error rate of a digital communication system.
The error and complementary error functions occur, for example, in solutions of the heat equation when boundary conditions are given by the Heaviside step function.
The error function and its approximations can be used to estimate results that hold with high probability or with low probability. Given a normally distributed random variable with mean and standard deviation and a constant , it can be shown (via integration by substitution) that
where and are certain numeric constants. If is sufficiently far from the mean, specifically, , then
and so the probability goes to 0 as .
The probability for being in the interval can be derived as
Properties
Script error: No such module "Multiple image".
The error function is an odd function. This directly results from the fact that the integrand is an even function (since the antiderivative of an even function which is zero at the origin is an odd function, and vice versa).
Since the error function is an entire function which maps real numbers to real numbers, for any complex number ,
where denotes the complex conjugate of .
The error function at is exactly (see Gaussian integral). At the real axis, approaches at and at . At the imaginary axis, it tends to .
Taylor series
The error function is an entire function; it has no singularities (except at infinity) and its Taylor expansion always converges. For , however, cancellation of leading terms makes the Taylor expansion impractical.
The defining integral cannot be evaluated in closed form in terms of elementary functions (see Liouville's theorem), but by expanding the integrand into its Maclaurin series, integrating term by term,Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". and using the fact that , one obtains the error function's Maclaurin series as: which holds for every complex number . The denominator terms form sequence A007680 in the OEIS. This is a special case of Kummer's function:
For iterative calculation of the above series, the following alternative formulation may be useful: because
expresses the multiplier to turn the -th term into the -th term (considering as the first term).
The imaginary error function has a similar Maclaurin series: which holds for every complex number .
Derivative and integral
The derivative of the error function follows immediately from its definition: From this, the derivative of the imaginary error function is also immediate: Higher order derivatives are given by where the are the physicists' Hermite polynomials.[1]
An antiderivative of the error function, obtainable by integration by parts, is An antiderivative of the imaginary error function, also obtainable by integration by parts, is
BΓΌrmann series
An expansion which converges more rapidly for all real values of than a Taylor expansionScript error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". is obtained by using BΓΌrmann's theorem:[2] where is the sign function. By keeping only the first two coefficients and choosing and , the resulting approximation shows its largest relative error at , where it is less than :
Inverse functions
Given a complex number , there is not a unique complex number satisfying , so a true inverse function would be multivalued. However, for , there is a unique real number denoted satisfying
The inverse error function is usually defined with domain , and it is restricted to this domain in many computer algebra systems. However, it can be extended to the disk of the complex plane, using the Maclaurin series[3] where and
So we have the series expansion (common factors have been canceled from numerators and denominators):
(After cancellation the numerator and denominator values in (sequence A092676 in the OEIS) and (sequence A092677 in the OEIS) respectively; without cancellation the numerator terms are values in (sequence A002067 in the OEIS).) The error function's value at is equal to .
For , we have .
The inverse complementary error function is defined as For real , there is a unique real number satisfying . The inverse imaginary error function is defined as .[4]
For any real , Newton's method can be used to compute , and for , the following Maclaurin series converges:
where is defined as above.
Asymptotic expansion
A useful asymptotic expansion of the complementary error function (and therefore also of the error function) for large real is where is the double factorial of , i.e. the product of all odd numbers up to . This series diverges for every finite , and its meaning as asymptotic expansion is that for any integer one has
where the remainder is
which follows easily by induction, writing
and integrating by parts. The asymptotic behavior of the remainder term is
as . This can be found by
For large enough values of , only the first few terms of this asymptotic expansion are needed to obtain a good approximation of (while for not too large values of , the above Taylor expansion at 0 provides a very fast convergence).
Continued fraction expansion
A continued fraction expansion of the complementary error function was found by Laplace:Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters".Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". where .
Factorial series
The inverse factorial series
converges for . Here
where denotes the rising factorial, and denotes a signed Stirling number of the first kind.[5]Script error: No such module "Footnotes".Script error: No such module "Check for unknown parameters". The Taylor series can be written in terms of the double factorial:
Bounds and numerical approximations
Approximation with elementary functions
Abramowitz and Stegun give several approximations of varying accuracy (equations 7.1.25β28). This allows one to choose the fastest approximation suitable for a given application. In order of increasing accuracy, they are: (maximum error: Script error: No such module "val".) Template:Pb where a1 = 0.278393Script error: No such module "Check for unknown parameters"., a2 = 0.230389Script error: No such module "Check for unknown parameters"., a3 = 0.000972Script error: No such module "Check for unknown parameters"., a4 = 0.078108Script error: No such module "Check for unknown parameters".
(maximum error: Script error: No such module "val".) Template:Pb where p = 0.47047Script error: No such module "Check for unknown parameters"., a1 = 0.3480242Script error: No such module "Check for unknown parameters"., a2 = β0.0958798Script error: No such module "Check for unknown parameters"., a3 = 0.7478556Script error: No such module "Check for unknown parameters".
(maximum error: Script error: No such module "val".) Template:Pb where a1 = 0.0705230784Script error: No such module "Check for unknown parameters"., a2 = 0.0422820123Script error: No such module "Check for unknown parameters"., a3 = 0.0092705272Script error: No such module "Check for unknown parameters"., a4 = 0.0001520143Script error: No such module "Check for unknown parameters"., a5 = 0.0002765672Script error: No such module "Check for unknown parameters"., a6 = 0.0000430638Script error: No such module "Check for unknown parameters".
(maximum error: Script error: No such module "val".) Template:Pb where p = 0.3275911Script error: No such module "Check for unknown parameters"., a1 = 0.254829592Script error: No such module "Check for unknown parameters"., a2 = β0.284496736Script error: No such module "Check for unknown parameters"., a3 = 1.421413741Script error: No such module "Check for unknown parameters"., a4 = β1.453152027Script error: No such module "Check for unknown parameters"., a5 = 1.061405429Script error: No such module "Check for unknown parameters". Template:Pb
One can improve the accuracy of the A&S approximation by extending it with three extra parameters, where p1 = 0.406742016006509, p2 = 0.0072279182302319, a1 = 0.316879890481381, a2 = -0.138329314150635, a3 = 1.08680830347054, a4 = -1.11694155120396, a5 = 1.20644903073232, a6 = -0.393127715207728, a7 = 0.0382613542530727. The maximum error of this approximation is about Script error: No such module "val".. The parameters are obtained by fitting the extended approximation to the accurate values of the error function using the following Python code. Page Template:Collapse top/styles.css has no content.
Python code to fit extended A&S approximation
|
|---|
import numpy as np
from math import erf, exp, sqrt
from scipy.optimize import least_squares
#
# Extended A&S approximation:
# erf(x) β 1 β t * exp(βx^2) * (a1 + a2*t + a3*t^2 + ... + a7*t^6)
# where now
# t = 1 / (1 + p1*x + p2*x^2)
# We fit parameters p1, p2, a1..a7 over x in [0, 10].
#
def approx_erf(params, x):
p1 = params[0]
p2 = params[1]
a = params[2:]
t = 1.0 / (1.0 + p1 * x + p2 * x * x)
poly = np.zeros_like(x)
tt = np.ones_like(x) # t^0
# polynomial: a1*t^0 + a2*t^1 + ... + a7*t^6
for ak in a:
poly += ak * tt
tt *= t
return 1.0 - t * np.exp(-x * x) * poly
def residuals(params, xs, ys):
return approx_erf(params, xs) - ys
#
# Prepare data for fitting
#
N = 300
xmin = 0
xmax = 10
xs = np.linspace(xmin, xmax, N)
ys = np.array([erf(x) for x in xs], dtype=float)
#
# Initial guess for parameters
# Start from original A&S values and extend them conservatively
#
p1_0 = 0.3275911 # original A&S p
p2_0 = 0.0 # new denominator parameter
# original A&S 5 coefficients, add two => 7 in total
a0 = [
0.254829592,
-0.284496736,
1.421413741,
-1.453152027,
1.061405429,
0.0, # new term
0.0, # another new term
]
params0 = np.array([p1_0, p2_0] + a0, dtype=float)
#
# Fit using nonlinear least squares (LevenbergβMarquardt)
#
result = least_squares(
residuals, params0, args=(xs, ys), xtol=1e-14, ftol=1e-14, gtol=1e-14, max_nfev=5000
)
params = result.x
p1_fit = params[0]
p2_fit = params[1]
a_fit = params[2:]
#
# Print fitted parameters
#
print("\nFitted parameters:")
print(f"p1 = {p1_fit:.15g},")
print(f"p2 = {p2_fit:.15g},")
for i, ai in enumerate(a_fit, 1):
print(f"a{i} = {ai:.15g},")
#
# Evaluate approximation error
#
approx_vals = approx_erf(params, xs)
abs_err = np.abs(approx_vals - ys)
print(f"\nMaximum absolute error on [{xmin},{xmax}]:", np.max(abs_err))
print("RMS error:", np.sqrt(np.mean(abs_err**2)))
print("Done.")
|
All of these approximations are valid for x β₯ 0Script error: No such module "Check for unknown parameters".. To use these approximations for negative x, use the fact that erf(x)Script error: No such module "Check for unknown parameters". is an odd function, so erf(x) = βerf(βx)Script error: No such module "Check for unknown parameters"..
Exponential bounds and a pure exponential approximation for the complementary error function are given by[6]
The above have been generalized to sums of N exponentials[7] with increasing accuracy in terms of N so that erfc(x)Script error: No such module "Check for unknown parameters". can be accurately approximated or bounded by 2QΜ(√2x)Script error: No such module "Check for unknown parameters"., where In particular, there is a systematic methodology to solve the numerical coefficients {(an,bn)}Script error: No such module "Su".Script error: No such module "Check for unknown parameters". that yield a minimax approximation or bound for the closely related Q-function: Q(x) β QΜ(x)Script error: No such module "Check for unknown parameters"., Q(x) β€ QΜ(x)Script error: No such module "Check for unknown parameters"., or Q(x) β₯ QΜ(x)Script error: No such module "Check for unknown parameters". for x β₯ 0Script error: No such module "Check for unknown parameters".. The coefficients {(an,bn)}Script error: No such module "Su".Script error: No such module "Check for unknown parameters". for many variations of the exponential approximations and bounds up to N = 25Script error: No such module "Check for unknown parameters". have been released to open access as a comprehensive dataset.[8]
A tight approximation of the complementary error function for x β [0,β)Script error: No such module "Check for unknown parameters". is given by Karagiannidis & Lioumpas (2007),[9] who showed for the appropriate choice of parameters {A,B}Script error: No such module "Check for unknown parameters". that
They determined {A,B} = {1.98,1.135}Script error: No such module "Check for unknown parameters"., which gave a good approximationTemplate:Which? for all x β₯ 0Script error: No such module "Check for unknown parameters".. Alternative coefficients are also available for tailoring accuracy for a specific application or transforming the expression into a tight bound.[10]
A single-term lower bound is[11] where the parameter Ξ² can be picked to minimize error on the desired interval of approximation.
Another approximation is given by Sergei Winitzki using his "global PadΓ© approximations":[12][13]Template:Rp where This is designed to be very accurate in the neighborhoods of 0 and infinity, and the relative error is less than 0.00035 for all real x. Using the alternate value a β 0.147Script error: No such module "Check for unknown parameters". reduces the maximum relative error to about 0.00013.[14] Template:Pb
The extended "global Pade" approximation, provides a maximum error of about Script error: No such module "val"., as demonstrated by the following Python script. Page Template:Collapse top/styles.css has no content.
Python script to fit extended "global Pade" approximation
|
|---|
import numpy,math
from scipy.optimize import least_squares
# approximation to erf(x)
def approx_erf(p,x):
frac=(4+p[0]*x**2+p[1]*x**4+p[2]*x**6)/(
math.pi+p[3]*x**2+p[4]*x**4+p[5]*x**6)
return numpy.sign(x)*numpy.sqrt(
1-numpy.exp(-x*x*frac))
def residuals(params, xs, ys):
return approx_erf(params, xs) - ys
# data for fitting
N = 200
xmin = 0
xmax = 9
xs = numpy.linspace(xmin, xmax, N)
ys = numpy.array([math.erf(x) for x in xs], dtype=float)
params0 = numpy.array([0.9,0.1,0.008,0.8,0.1,0.008], dtype=float)
# fitting
result = least_squares(
residuals, params0, args=(xs, ys),
xtol=1e-14, ftol=1e-14, gtol=1e-14, max_nfev=5000
)
params = result.x
# print out fitted parameters
print("\nFitted parameters:")
for i, pi in enumerate(params, 0):
print(f"p{i} = {pi:.15g},")
# evaluate approximation error
approx_vals = approx_erf(params, xs)
abs_err = numpy.abs(approx_vals - ys)
print(f"\nMaximum absolute error on [{xmin},{xmax}]:", numpy.max(abs_err))
print("RMS error:", numpy.sqrt(numpy.mean(abs_err**2)))
print("Done.")
|
Winitzki's approximation can be inverted to obtain an approximation for the inverse error function:
An approximation with a maximal error of Script error: No such module "val". for any real argument is:[15]
An approximation of with a maximum relative error less than in absolute value is:[16] for , and for
A simple approximation for real-valued arguments can be done through hyperbolic functions: which keeps the absolute difference .
Since the error function and the Gaussian Q-function are closely related through the identity or equivalently , bounds developed for the Q-function can be adapted to approximate the complementary error function. A pair of tight lower and upper bounds on the Gaussian Q-function for positive arguments was introduced by Abreu (2012)[17] based on a simple algebraic expression with only two exponential terms:
These bounds stem from a unified form where the parameters and are selected to ensure the bounding properties: for the lower bound, and , and for the upper bound, and . These expressions maintain simplicity and tightness, providing a practical trade-off between accuracy and ease of computation. They are particularly valuable in theoretical contexts, such as communication theory over fading channels, where both functions frequently appear. Additionally, the original Q-function bounds can be extended to for positive integers via the binomial theorem, suggesting potential adaptability for powers of , though this is less commonly required in error function applications.
Table of values
Script error: No such module "Unsubst".
| xScript error: No such module "Check for unknown parameters". | erf(x)Script error: No such module "Check for unknown parameters". | 1 β erf(x)Script error: No such module "Check for unknown parameters". |
|---|---|---|
| 0 | Script error: No such module "val". | Script error: No such module "val". |
| 0.02 | Script error: No such module "val". | Script error: No such module "val". |
| 0.04 | Script error: No such module "val". | Script error: No such module "val". |
| 0.06 | Script error: No such module "val". | Script error: No such module "val". |
| 0.08 | Script error: No such module "val". | Script error: No such module "val". |
| 0.1 | Script error: No such module "val". | Script error: No such module "val". |
| 0.2 | Script error: No such module "val". | Script error: No such module "val". |
| 0.3 | Script error: No such module "val". | Script error: No such module "val". |
| 0.4 | Script error: No such module "val". | Script error: No such module "val". |
| 0.5 | Script error: No such module "val". | Script error: No such module "val". |
| 0.6 | Script error: No such module "val". | Script error: No such module "val". |
| 0.7 | Script error: No such module "val". | Script error: No such module "val". |
| 0.8 | Script error: No such module "val". | Script error: No such module "val". |
| 0.9 | Script error: No such module "val". | Script error: No such module "val". |
| 1 | Script error: No such module "val". | Script error: No such module "val". |
| 1.1 | Script error: No such module "val". | Script error: No such module "val". |
| 1.2 | Script error: No such module "val". | Script error: No such module "val". |
| 1.3 | Script error: No such module "val". | Script error: No such module "val". |
| 1.4 | Script error: No such module "val". | Script error: No such module "val". |
| 1.5 | Script error: No such module "val". | Script error: No such module "val". |
| 1.6 | Script error: No such module "val". | Script error: No such module "val". |
| 1.7 | Script error: No such module "val". | Script error: No such module "val". |
| 1.8 | Script error: No such module "val". | Script error: No such module "val". |
| 1.9 | Script error: No such module "val". | Script error: No such module "val". |
| 2 | Script error: No such module "val". | Script error: No such module "val". |
| 2.1 | Script error: No such module "val". | Script error: No such module "val". |
| 2.2 | Script error: No such module "val". | Script error: No such module "val". |
| 2.3 | Script error: No such module "val". | Script error: No such module "val". |
| 2.4 | Script error: No such module "val". | Script error: No such module "val". |
| 2.5 | Script error: No such module "val". | Script error: No such module "val". |
| 3 | Script error: No such module "val". | Script error: No such module "val". |
| 3.5 | Script error: No such module "val". | Script error: No such module "val". |
Related functions
Complementary error function

The complementary error function, denoted erfcScript error: No such module "Check for unknown parameters"., is defined as which also defines erfcxScript error: No such module "Check for unknown parameters"., the scaled complementary error function[18] (which can be used instead of erfcScript error: No such module "Check for unknown parameters". to avoid arithmetic underflow[18][19]). Another form of erfc xScript error: No such module "Check for unknown parameters". for x β₯ 0Script error: No such module "Check for unknown parameters". is known as Craig's formula, after its discoverer:[20] This expression is valid only for positive values of x, but can be used in conjunction with erfc(x) = 2 β erfc(βx)Script error: No such module "Check for unknown parameters". to obtain erfc(x)Script error: No such module "Check for unknown parameters". for negative values. This form is advantageous in that the range of integration is fixed and finite. An extension of this expression for the erfcScript error: No such module "Check for unknown parameters". of the sum of two non-negative variables is[21]
Imaginary error function

The imaginary error function, denoted erfiScript error: No such module "Check for unknown parameters"., is defined as where D(x)Script error: No such module "Check for unknown parameters". is the Dawson function (which can be used instead of erfiScript error: No such module "Check for unknown parameters". to avoid arithmetic overflow[18]).
Despite the name "imaginary error function", erfi(x)Script error: No such module "Check for unknown parameters". is real when x is real.
When the error function is evaluated for arbitrary complex arguments z, the resulting complex error function is usually discussed in scaled form as the Faddeeva function:
Cumulative distribution function

The error function is essentially identical to the standard normal cumulative distribution function, denoted Ξ¦Script error: No such module "Check for unknown parameters"., also named norm(x)Script error: No such module "Check for unknown parameters". by some software languagesScript error: No such module "Unsubst"., as they differ only by scaling and translation. Indeed, or rearranged for erfScript error: No such module "Check for unknown parameters". and erfcScript error: No such module "Check for unknown parameters".:
Consequently, the error function is also closely related to the Q-function, which is the tail probability of the standard normal distribution. The Q-function can be expressed in terms of the error function as
The inverse of Ξ¦Script error: No such module "Check for unknown parameters". is known as the normal quantile function, or probit function and may be expressed in terms of the inverse error function as
The standard normal cdf is used more often in probability and statistics, and the error function is used more often in other branches of mathematics.
The error function is a special case of the Mittag-Leffler function, and can also be expressed as a confluent hypergeometric function (Kummer's function):
It has a simple expression in terms of the Fresnel integral.Template:Elucidate
In terms of the regularized gamma function P and the incomplete gamma function, sgn(x)Script error: No such module "Check for unknown parameters". is the sign function.
Iterated integrals of the complementary error function
The iterated integrals of the complementary error function are defined by[22]
The general recurrence formula is
They have the power series from which follow the symmetry properties and
Implementations
As real function of a real argument
- In POSIX-compliant operating systems, the header
math.hshall declare and the mathematical librarylibmshall provide the functionserfanderfc(double precision) as well as their single precision and extended precision counterpartserff,erflanderfcf,erfcl.[23] - The GNU Scientific Library provides
erf,erfc,log(erf), and scaled error functions.[24]
As complex function of a complex argument
libcerf, numeric C library for complex error functions, provides the complex functionscerf,cerfc,cerfcxand the real functionserfi,erfcxwith approximately 13β14 digits precision, based on the Faddeeva function as implemented in the MIT Faddeeva Package
Notes
Page Template:Reflist/styles.css has no content.
- β Script error: No such module "Template wrapper".
- β Script error: No such module "Template wrapper".
- β Script error: No such module "citation/CS1".
- β Script error: No such module "citation/CS1".
- β Script error: No such module "Citation/CS1".
- β Script error: No such module "Citation/CS1".
- β Script error: No such module "Citation/CS1".
- β Script error: No such module "Citation/CS1".
- β Script error: No such module "Citation/CS1".
- β Script error: No such module "Citation/CS1".
- β Script error: No such module "Citation/CS1".
- β Script error: No such module "citation/CS1".
- β Script error: No such module "Citation/CS1".
- β Script error: No such module "citation/CS1".
- β Script error: No such module "citation/CS1".
- β Script error: No such module "Citation/CS1".
- β Script error: No such module "Citation/CS1".
- β a b c Script error: No such module "citation/CS1".
- β Script error: No such module "citation/CS1".
- β John W. Craig, A new, simple and exact result for calculating the probability of error for two-dimensional signal constellations Script error: No such module "webarchive"., Proceedings of the 1991 IEEE Military Communication Conference, vol. 2, pp. 571β575.
- β Script error: No such module "Citation/CS1".
- β Script error: No such module "citation/CS1".
- β Script error: No such module "citation/CS1".
- β Script error: No such module "citation/CS1".
Script error: No such module "Check for unknown parameters".
References
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "Citation/CS1".
- Script error: No such module "Citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "Citation/CS1".
- Script error: No such module "citation/CS1".
Further reading
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1".
- Script error: No such module "citation/CS1"..
External links
Template:Nonelementary Integral Script error: No such module "Authority control".