Qu

erf

Builtin index · Core maths

erf(x)

Input: x · Output: no output

What it is

The error function and its complement (erfc(x) = 1 - erf(x), computed directly rather than by subtraction so it stays accurate for large x, where erf(x) itself has already saturated to 1.0). x is a real scalar, Vec, or Mat/Signal; defined everywhere, no pole.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
erf(x)
x scalar, Vec, Mat, or Signalnot documented yet
not documented yet—

Examples

No documentation example calls this form yet. The Core maths chapter is where one belongs.

How it works

erf/erfc: defined on the whole real line, no pole. erfc (x) = 1 - erf(x) mathematically, but computing it that way loses precision for large positive x: erf(x) saturates to 1.0 at double precision well before erfc(x) itself underflows to zero (erfc(6) is order 2e-17, nowhere near where 1.0 - erf(6) would still have any correct digits). libm::erfc computes the complementary form directly rather than subtracting, so it keeps precision into that tail -- see the erfc_of_large_x_does_not_cancel_to_nothing test below, which is exactly the case a naive 1.0 - erf(x) implementation gets wrong.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.

See also

erfc — documented in the same entry.