Reference · Math

math.erfc

signature
math.erfc(num) -> float

What it does

The complementary error function, 1 - erf(x), as Python's math.erfc, computed so that the small values in the tail keep their digits: 1 - math.erf(5) has lost most of them to cancellation, math.erfc(5) has not. It runs from 2 at minus infinity to 0 at plus infinity.

Examples

print(math.erfc(0), math.erfc(1), math.erfc(-1))print(math.erfc(5), 1 - math.erf(5))print(math.erf(0.5) + math.erfc(0.5))
output
1.0 0.15729920705028513 1.8427007929497150.0000000000015374597944280351 0.00000000000153743684450091681.0

Edge cases

print(math.erfc(2), math.erfc(28))print(math.erfc(float("inf")), math.erfc(float("-inf")), math.erfc(float("nan")))
output
0.004677734981047265 0.00.0 2.0 NaN

Errors

An argument that is not a number is a runtime error, not an error value. There is no domain error: every number has an answer.

this one fails
print(math.erfc(null))
output
line 1: `math.erfc` expects a number as argument 1, got null

Chaining

In a pipeline the number comes first. A two-sided p-value from a z-score:

print(1 | math.erfc)let z = 1.96print(math.fabs(z) / math.sqrt(2) | math.erfc | round(3))
output
0.157299207050285130.05

See also

math.erf, stats.normal_cdf, math.exp

Thread
8Useful? Like it, or add to its thread below.

Thread 0 posts

On math.erfc(): questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.

    Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo