erf
Error function. The input parameter is a real number.
Interface Definition
C interface:
float erff(float x);
double erf(double x);
double erf_18(double x);
long double erfl(long double x);
erf_18 is provided only in the high-precision version.
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
Return Value
- The error function computing result y of the input parameter x is returned. y ∈ [–1, +1]
- If the input is NaN, the return value is NaN.
- If the input is +∞, the return value is 1.
- If the input is –∞, the return value is –1.
- For the float interface, if x ≥ 0x1.F5AAp1, the return value is 1.
- For the float interface, if x ≤ –0x1.F5AAp1, the return value is –1.
- For the double interface, if x ≥ 0x1.7afb48dc96628p+2, the return value is 1.
- For the double interface, if x ≤ –0x1.7afb48dc96628p+2, the return value is –1.
Dependency
C: "km.h"
Example
C interface:
// print result
printf("erf(0.0) = %.15f\n", erf(0.0));
printf("erf(-0.0) = %.15f\n", erf(-0.0));
printf("erf(0.25) = %.15f\n", erf(0.25));
printf("erf(-0.25) = %.15f\n", erf(-0.25));
printf("erf(0.5) = %.15f\n", erf(0.5));
printf("erf(-0.5) = %.15f\n", erf(-0.5));
printf("erf(1.0) = %.15f\n", erf(1.0));
printf("erf(-1.0) = %.15f\n", erf(-1.0));
printf("erf(2.0) = %.15f\n", erf(2.0));
printf("erf(-2.0) = %.15f\n", erf(-2.0));
printf("erf(INFINITY) = %.15f\n", erf(INFINITY));
printf("erf(-INFINITY) = %.15f\n", erf(-INFINITY));
printf("erf(NAN) = %.15f\n", erf(NAN));
printf("erf(-NAN) = %.15f\n", erf(-NAN));
/*
* erf(0.0) = 0.000000000000000
* erf(-0.0) = -0.000000000000000
* erf(0.25) = 0.276326390168237
* erf(-0.25) = -0.276326390168237
* erf(0.5) = 0.520499877813047
* erf(-0.5) = -0.520499877813047
* erf(1.0) = 0.842700792949715
* erf(-1.0) = -0.842700792949715
* erf(2.0) = 0.995322265018953
* erf(-2.0) = -0.995322265018953
* erf(INFINITY) = 1.000000000000000
* erf(-INFINITY) = -1.000000000000000
* erf(NAN) = nan
* erf(-NAN) = -nan
*
* */
Parent topic: Function Syntax