erf(x)

Error Function Calculator

erf(x) · erfc(x) · erfcx(x) · erfi(x) · Tables · Step-by-step

Quick Examples

Any real number. For erfi, large |x| may be slow to compute.

What is the Error Function?

The error function, denoted erf(x), is one of the most important special functions in mathematics and applied science. It is defined as the integral erf(x) = (2/√π) ∫₀ˣ e⁻t² dt. The factor 2/√π normalizes the function so that erf(∞) = 1. The function outputs values between −1 and +1, is odd (erf(−x) = −erf(x)), and is strictly increasing. It emerges naturally whenever Gaussian integrals appear in a context with a finite upper limit — which happens in probability theory, heat conduction, and diffusion.

The name "error function" comes from the theory of observational errors in astronomy and surveying, where Gauss and Laplace used it to describe the probability that a measurement error falls within a given range. Today it is indispensable in statistics (it gives the CDF of the normal distribution), physics (diffusion, the heat equation), and engineering (communications, signal detection).

Complementary Error Function (erfc)

The complementary error function is simply erfc(x) = 1 − erf(x). It represents the probability mass in the tail of the Gaussian beyond x. While erf(x) focuses on accumulated probability from 0 to x, erfc(x) focuses on the remaining tail from x to ∞. Special values are erfc(0) = 1 and erfc(∞) = 0. In reliability engineering, erfc often appears directly because you care about failure probabilities — the chance that a quantity exceeds a threshold — rather than the accumulated mass below it.

For large positive x, erfc(x) decays very rapidly: erfc(1) ≈ 0.1573, erfc(2) ≈ 0.00468, erfc(3) ≈ 0.0000221. This fast decay makes direct computation numerically unstable for large x, which motivates the scaled version erfcx.

How to Calculate erf(x) — Abramowitz & Stegun Approximation

While erf(x) has no closed-form expression in terms of elementary functions, it can be computed to high accuracy using rational polynomial approximations. The most widely used approximation is from Abramowitz and Stegun (formula 7.1.26), which achieves a maximum absolute error of less than 1.5 × 10⁻⁷ across all real x:

Set t = 1/(1 + 0.3275911 |x|), then compute the polynomial p(t) = t(0.254829592 + t(−0.284496736 + t(1.421413741 + t(−1.453152027 + t · 1.061405429)))), and finally erf(x) = sign(x) · (1 − p(t) · e⁻x²). This five-coefficient Horner-form polynomial runs in constant time and is the standard choice in most scientific computing libraries.

Common Values of erf(x)

xerf(x)erfc(x)erfcx(x)
00.0000001.0000001.000000
0.50.5205000.4795000.615080
10.8427010.1572990.427584
1.50.9661050.0338950.253994
20.9953220.0046780.134641
30.9999780.0000220.057289

Applications of the Error Function

Normal Distribution and Probability

For a standard normal variable Z ~ N(0,1), P(−x ≤ Z ≤ x) = erf(x/√2). Equivalently, the normal CDF is Φ(x) = (1 + erf(x/√2))/2. This means every probability calculation involving the normal distribution can be expressed in terms of erf. In Python's SciPy, scipy.special.erf is directly accessible; in C99 and C++11, std::erf is a standard library function.

Heat Conduction and Diffusion

The solution to the one-dimensional heat equation ∂T/∂t = α ∂²T/∂x² in a semi-infinite medium with a step-change boundary condition is T(x,t) = T₀ erfc(x / (2√(αt))). Here, α is the thermal diffusivity. The argument x/(2√(αt)) is the dimensionless similarity variable for diffusion problems. This formula is used to compute how far heat (or a diffusing species) has penetrated into a material at time t — essential in materials science, geophysics, and semiconductor fabrication.

Signal Processing and Communications

In digital communications, the bit error rate (BER) for binary phase-shift keying (BPSK) transmitted over an additive white Gaussian noise (AWGN) channel is BER = erfc(√(Eₛ/N₀))/2, where Eₛ/N₀ is the signal-to-noise ratio per bit. The Q-function used in communications is Q(x) = erfc(x/√2)/2. System designers use erfc tables and calculators to determine the minimum transmit power needed to achieve a target error rate, making erfc fundamental to wireless communication system design.

erfc vs erfcx — When to Use Each

For small to moderate values of x (roughly |x| ≤ 3), computing erfc(x) = 1 − erf(x) directly is numerically stable. However, for large positive x, erfc(x) becomes extremely small (e.g., erfc(5) ≈ 1.54 × 10⁻²²), and floating-point cancellation errors in 1 − erf(x) dominate. The scaled function erfcx(x) = e^(x²) · erfc(x) avoids this: for x = 5, erfcx(5) ≈ 0.1107, a perfectly representable number. After obtaining erfcx(x), you can recover erfc(x) = erfcx(x) · e^(−x²) using high-precision arithmetic only when needed. Use erfcx when computing erfc for arguments x > 3 in any numerically sensitive context.

Frequently Asked Questions

What is the error function erf(x)?
The error function erf(x) is defined as erf(x) = (2/√π) ∫₀ˣ e⁻t² dt. It ranges from −1 to +1, equals 0 at x=0, and tends to 1 as x→∞. It is directly related to the normal distribution: P(|Z|≤x) = erf(x/√2) for Z~N(0,1). The function is odd: erf(−x) = −erf(x).
What is the complementary error function erfc(x)?
erfc(x) = 1 − erf(x) = (2/√π) ∫ˣ∞ e⁻t² dt. It represents the tail probability of the Gaussian integral. erfc(0) = 1, erfc(∞) = 0. Used in survival analysis, reliability theory, and tail probability calculations.
What is erfcx(x)?
erfcx(x) = e^(x²) · erfc(x) is the scaled complementary error function. It avoids the numerical underflow that occurs when erfc(x) → 0 for large x. For large x, erfcx(x) ≈ 1/(x√π). Use erfcx when computing erfc for x > 3 in numerically sensitive applications.
What is erfi(x) (imaginary error function)?
erfi(x) = −i · erf(ix) = (2/√π) ∫₀ˣ e^(t²) dt. Unlike erf, erfi grows without bound as x→∞ because the integrand e^(t²) is unbounded. It arises in Fresnel integrals, quantum mechanics, and some solutions of the heat equation with growing sources.
How is erf related to the normal distribution?
For Z ~ N(0,1): P(−x ≤ Z ≤ x) = erf(x/√2). The normal CDF is Φ(x) = (1 + erf(x/√2))/2. For general X ~ N(μ, σ²): P(a ≤ X ≤ b) = [erf((b−μ)/(σ√2)) − erf((a−μ)/(σ√2))]/2.
What are the special values of erf?
erf(0) = 0, erf(0.5) ≈ 0.5205, erf(1) ≈ 0.8427, erf(1.5) ≈ 0.9661, erf(2) ≈ 0.9953, erf(3) ≈ 0.9999978, erf(∞) = 1. The function is odd: erf(−x) = −erf(x). Already at x = 2 the function is within 0.5% of its limit of 1.
Where is the error function used?
Statistics (normal distribution CDF), heat transfer and diffusion (semi-infinite medium solutions), signal processing (bit error rates in AWGN channels — Q-function), quantum mechanics (harmonic oscillator), chemistry (diffusion-limited reactions), and geophysics (temperature profiles in the Earth's crust).