erf, erff, erfl, erfd32, erfd64, and erfd128 Subroutines

Purpose

Computes the error and complementary error functions.

Libraries

IEEE Math Library (libm.a) or System V Math Library (libmsaa.a)

Syntax

#include <math.h>
double erf ( x)
double x;
float erff (x)
float x;
long double erfl (x)
long double x;
_Decimal32 erfd32 (x)
_Decimal32 x;

_Decimal64 erfd64 (x)
_Decimal64 x;

_Decimal128 erfd128 (x)
_Decimal128 x;

Description

The erf, erff, erfl, erfd32, erfd64, and erfd128 subroutines return the error function of the x parameter, defined for the erf subroutine as the following:

erf(x) = (2/sqrt(pi) * (integral [0 to x] of exp(-(t**2)) dt)
erfc(x) = 1.0 - erf(x)
Note: Compile any routine that uses subroutines from the libm.a library with the -lm flag. To compile the erf.c file, for example, enter:
cc erf.c -lm

An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. Upon return, if errno is nonzero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is nonzero, an error has occurred.

Parameters

Item Description
x Specifies a double-precision floating-point value.

Return Values

Upon successful completion, the erf, erff, erfl, erfd32, erfd64, and erfd128 subroutines return the value of the error function.

If x is NaN, a NaN is returned.

If x is ±0, ±0 is returned.

If x is ±Inf, ±1 is returned.

If x is subnormal, a range error may occur, and 2 * x/sqrt(pi) should be returned.