erfc, erfcf, erfcl
來自 cppreference.com
定義於標頭檔案 <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 erfc 函式 (p: 249-250)
- 7.25 型別通用數學 <tgmath.h> (p: 373-375)
- F.10.5.2 erfc 函式 (p: 525)
- C17 標準 (ISO/IEC 9899:2018)
- 7.12.8.2 erfc 函式 (p: 249-250)
- 7.25 型別通用數學 <tgmath.h> (p: 373-375)
- F.10.5.2 erfc 函式 (p: 525)
- 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)
[編輯] 另請參閱
(C99)(C99)(C99) |
計算誤差函式 (函式) |
C++ 文件 用於 erfc
|
[編輯] 外部連結
Weisstein, Eric W. "Erfc." 來自 MathWorld — A Wolfram Web Resource。 |