erfc, erfcf, erfcl
提供: cppreference.com
ヘッダ <math.h> で定義 | ||
float erfcf(float arg ); | (1) | (C99以上) |
double erfc(double arg ); | (2) | (C99以上) |
longdouble erfcl(longdouble arg ); | (3) | (C99以上) |
ヘッダ <tgmath.h> で定義 | ||
#define erfc( arg ) | (4) | (C99以上) |
4) 型総称マクロ。
arg
が longdouble 型の場合は 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 であればアンダーフローが保証されます。
[編集]例
Run this code
#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 standard (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 standard (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) | 誤差関数を計算します (関数) |
erfc の C++リファレンス |