math.erfc(x) returns the complementary error function1.0 - math.erf(x), evaluated directly in Python 3.2+ so tiny upper-tail values keep full precision.
Once x passes around 6, 1.0 - math.erf(x) collapses to 0.0 due to rounding, whereas math.erfc(x) stays accurate far down into sub-epsilon probability tails.
math.erfc() is a function in Python's standard math module: import it with import math and call math.erfc(...), or import the name directly with from math import erfc.
Syntax
Import math and pass any real number.
python
import math
tail = math.erfc(x)
Call
What it does
math.erfc(0)
Returns 1.0.
math.erfc(float("inf"))
Returns 0.0.
math.erfc(float("-inf"))
Returns 2.0.
math.erfc(6.0)
Returns approximately 2.151974e-17 (unlike 1 - erf(6)).
Use math.erfc(abs(z) / math.sqrt(2.0)) for two-tailed normal p-values and 0.5 * math.erfc(z / math.sqrt(2.0)) for one-tailed upper p-values.
Function signatures
python
math.erfc(x, /)
# added in Python 3.2; returns float 1.0 - erf(x) with full tail precision
Parameters
Parameter
Description
x
Required positional real number (int or float).
Return Value
Return Value
Description
float
Value in [0.0, 2.0]; 0.0 for inf, 2.0 for -inf, nan for nan.
Python Examples
Example 1 — Avoid Tail Precision Loss at x = 6.0 With erfc()
Compare 1.0 - math.erf(x) (which drops to zero) against math.erfc(x).
python
import math
for x in [2.0, 4.0, 6.0]:
naive = 1.0 - math.erf(x)
exact = math.erfc(x)
print(f"x={x:.0f} | 1-erf={naive:.6e} | erfc={exact:.6e}")