erfc, erfcf, erfcl
From 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 | - | floating-point value |
[編集] 戻り値
エラーが発生しなかった場合、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 型総称数学関数 <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 型総称数学関数 <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 型総称数学関数 <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 型総称数学関数 <tgmath.h> (p: 335-337)
- F.9.5.2 The erfc functions (p: 462)
[編集] 関連項目
| (C99)(C99)(C99) |
誤差関数を計算する (関数) |
| C++ ドキュメント : erfc
| |
[編集] 外部リンク
| Weisstein, Eric W. "Erfc." From MathWorld — A Wolfram Web Resource. |