erfcf
在头文件<math.h>中定义 | | |
---|---|---|
float erfcf(float arg); | (1) | (自C99以来) |
double erfc(double arg); | (2) | (自C99以来) |
long double erfcl(long double arg); | (3) | (自C99以来) |
在头文件<tgmath.h>中定义 | | |
#define erfc(arg) | (4) | (自C99以来) |
1-3)计算arg的补充误差函数,即1.0-erf(arg),但不会损失大的精度。
4)类型 - 通用宏:如果arg的类型为long double,则调用erfcl。 否则,如果arg具有整数类型或类型double,则调用erfc。 否则,调用erfcf。
参数
arg | - | floating point value |
---|
返回值
如果没有错误发生,补充错误函数的值arg
为:
| 2 |
|:----|
| √π |
∫∞
arge-t2
返回d t或1-erf(arg)。
如果由于下溢而发生范围错误,则返回正确的结果(舍入后)。
错误处理
按照math_errhandling中的指定报告错误。
如果实现支持IEEE浮点运算(IEC 60559),
- 如果参数是+∞,则返回+0
- 如果参数是-∞,则返回2
- 如果参数是NaN,则返回NaN
注意
对于兼容IEEE的类型double
,如果arg
> 26.55 ,则保证下溢。
例
#include <stdio.h>
#include <math.h>
double normalCDF(double x) // Phi(-∞, x) aka N(x)
{
return erfc(-x/sqrt(2))/2;
}
int main(void)
{
puts("normal cumulative distribution function:");
for(double n=0; n<1; n+=0.1)
printf("normalCDF(%.2f) %5.2f%%\n", n, 100*normalCDF(n));
puts("special values:");
printf("erfc(-Inf) = %f\n", erfc(-INFINITY));
printf("erfc(Inf) = %f\n", erfc(INFINITY));
}
输出:
normal cumulative distribution function:
normalCDF(0.00) 50.00%
normalCDF(0.10) 53.98%
normalCDF(0.20) 57.93%
normalCDF(0.30) 61.79%
normalCDF(0.40) 65.54%
normalCDF(0.50) 69.15%
normalCDF(0.60) 72.57%
normalCDF(0.70) 75.80%
normalCDF(0.80) 78.81%
normalCDF(0.90) 81.59%
normalCDF(1.00) 84.13%
special values:
erfc(-Inf) = 2.000000
erfc(Inf) = 0.000000
参考
- C11标准(ISO / IEC 9899:2011):
- 7.12.8.2 erfc函数(p:249-250)
- 7.25类型通用数学<tgmath.h>(p:373-375)
- F.10.5.2 erfc函数(p:525)
- C99标准(ISO / IEC 9899:1999):
- 7.12.8.2 erfc函数(p:230)
- 7.22类型通用数学<tgmath.h>(p:335-337)
- F.9.5.2 erfc函数(p:462)
扩展内容
erferfferfl (C99)(C99)(C99) | 计算错误函数(函数) |
---|
| 用于erfc的C ++文档 |
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com