erf, erff, erfl

Header: <math.h>

1-3) Computes the error function of arg.

# Declarations

float erff( float arg );

(since C99)

double erf( double arg );

(since C99)

long double erfl( long double arg );

(since C99)

#define erf( arg )

(since C99)

# Parameters

# Notes

Underflow is guaranteed if |arg| < DBL_MIN*(sqrt(π)/2).

# Example

#include <math.h>
#include <stdio.h>
 
double phi(double x1, double x2)
{
    return (erf(x2 / sqrt(2)) - erf(x1 / sqrt(2))) / 2;
}
 
int main(void)
{
    puts("normal variate probabilities:");
    for (int n = -4; n < 4; ++n)
        printf("[%2d:%2d]: %5.2f%%\n", n, n + 1, 100 * phi(n, n + 1));
 
    puts("special values:");
    printf("erf(-0) = %f\n", erf(-0.0));
    printf("erf(Inf) = %f\n", erf(INFINITY));
}

# See also