erf, erff, erfl, erfc, erfcf, erfcl

计算某个值的误差函数或补余误差函数。

语法

double erf(
   double x
);
float erf(
   float x
); // C++ only
long double erf(
   long double x
); // C++ only
float erff(
   float x
);
long double erfl(
   long double x
);
double erfc(
   double x
);
float erfc(
   float x
); // C++ only
long double erfc(
   long double x
); // C++ only
float erfcf(
   float x
);
long double erfcl(
   long double x
);
#define erf(X) // Requires C11 or higher
#define erfc(X) // Requires C11 or higher

参数

x
浮点值。

返回值

erf 函数返回 x 的高斯误差函数。 erfc 函数返回 x 的补余高斯误差函数。

备注

erf 函数计算 x 的高斯误差函数,定义如下:

The error function of x equals two over the square root of pi times the integral from zero to x of e to the minus t squared d t.

将补余高斯误差函数定义为 1 - erf(x)。 erf 函数返回一个介于 -1.0 到 1.0 之间的值。 无错误返回。 erfc 函数返回一个介于 0 到 2 之间的值。 如果 x 对于 erfc 而言太大,则将 errno 变量设置为 ERANGE

由于 C++ 支持重载,你可调用采用并返回 floatlong double 类型的 erferfc 重载。 在 C 程序中,除非使用 <tgmath.h> 宏来调用此函数,否则 erferfc 始终采用并返回 double

如果使用 <tgmath.h>erf() 宏,则参数的类型将决定选择哪个版本的函数。 有关详细信息,请参阅泛型类型数学

默认情况下,此函数的全局状态范围限定为应用程序。 若要更改此行为,请参阅 CRT 中的全局状态

要求

函数 必需的标头
erf, erff, erfl, erfc, erfcf, erfcl <math.h>
erf <tgmath.h>

有关兼容性的详细信息,请参阅 兼容性

另请参阅

数学和浮点支持