Standards / Extensions | C or C++ | Dependencies |
---|---|---|
SAA |
both |
#include <math.h>
double erf(double x);
double erfc(double x);
Compiler
option: LANGLVL(EXTENDED),
LANGLVL(SAA), or LANGLVL(SAA2) #define _XOPEN_SOURCE
#include <math.h>
double erf(double x);
double erfc(double x);
#define _ISOC99_SOURCE
#include <math.h>
float erff(float x);
long double erfl(long double x);
float erfcf(float x);
long double erfcl(long double x)
#define _TR1_C99
#include <math.h>
float erf(float x);
long double erf(long double x);
float erfc(float x);
long double erfc(long double x);
Calculates the error and complementary error functions:
Function | SPC | Hex | IEEE |
---|---|---|---|
erf | X | X | X |
erff | X | X | |
erfl | X | X | |
erfc | X | X | X |
erfcf | X | X | |
erfcl | X | X |
Both erf() and erfc() return the calculated value.
If the correct value would cause underflow, 0 is returned and the value of the macro ERANGE is stored in errno. A range error is returned if x is too large.
Special behavior for IEEE: erf() and erfc() are always successful.
This function is exposed by specifying on the compile step either the specific option LANGLVL(LONGLONG) or the general option LANGLVL(EXTENDED).
⁄* CELEBE01
This example uses &erf. and &erfc. to compute the error
function of two numbers.
*⁄
#include <stdio.h>
#include <math.h>
double smallx, largex, value;
int main(void)
{
smallx = 0.1;
largex = 10.0;
value = erf(smallx); ⁄* value = 0.112463 *⁄
printf("Error value for 0.1: %f\n", value);
value = erfc(largex); ⁄* value = 2.088488e-45 *⁄
printf("Error value for 10.0: %e\n", value);
}
Error value for 0.1: 0.112463
Error value for 10.0: 2.088488e-45