erfc, erfcf, erfcl
来自 cppreference.cn
定义于头文件 <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 起) |
4) 类型泛型宏:如果 arg 的类型是 long double,则调用
erfcl
。 否则,如果 arg 具有整数类型或类型 double,则调用 erfc
。 否则,调用 erfcf
。目录 |
[编辑] 参数
arg | - | 浮点数值 |
[编辑] 返回值
如果没有错误发生,则返回 arg 的互补误差函数值,即2 |
√π |
arge-t2
dt 或 1-erf(arg)。
如果由于下溢发生范围错误,则返回正确的结果(在舍入后)。
[编辑] 错误处理
错误报告如 math_errhandling
中指定。
如果实现支持 IEEE 浮点算术 (IEC 60559),
- 如果参数为 +∞,则返回 +0。
- 如果参数为 -∞,则返回 2。
- 如果参数是 NaN,则返回 NaN。
[编辑] 注意
对于 IEEE 兼容类型 double
,如果 arg > 26.55,则保证发生下溢。
[编辑] 示例
运行此代码
#include <math.h> #include <stdio.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)); printf("special values:\n" "erfc(-Inf) = %f\n" "erfc(Inf) = %f\n", erfc(-INFINITY), 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
[编辑] 参考文献
- C23 标准 (ISO/IEC 9899:2024)
- 7.12.8.2 The erfc functions (p: 249-250)
- 7.25 Type-generic math <tgmath.h> (p: 373-375)
- F.10.5.2 The erfc functions (p: 525)
- C17 标准 (ISO/IEC 9899:2018)
- 7.12.8.2 The erfc functions (p: 249-250)
- 7.25 Type-generic math <tgmath.h> (p: 373-375)
- F.10.5.2 The erfc functions (p: 525)
- C11 标准 (ISO/IEC 9899:2011)
- 7.12.8.2 The erfc functions (p: 249-250)
- 7.25 Type-generic math <tgmath.h> (p: 373-375)
- F.10.5.2 The erfc functions (p: 525)
- C99 标准 (ISO/IEC 9899:1999)
- 7.12.8.2 The erfc functions (p: 230)
- 7.22 Type-generic math <tgmath.h> (p: 335-337)
- F.9.5.2 The erfc functions (p: 462)
[编辑] 参见
(C99)(C99)(C99) |
计算误差函数 (函数) |
C++ 文档 for erfc
|
[编辑] 外部链接
Weisstein, Eric W. "Erfc." 来自 MathWorld — Wolfram Web 资源。 |