erfc, erfcf, erfcl
From cppreference.net
Common mathematical functions
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
ヘッダーで定義
<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 | - | 浮動小数点値 |
戻り値
If no errors occur, value of the complementary error function of arg , that is \(\frac{2}{\sqrt{\pi} }\int_{arg}^{\infty}{e^{-{t^2} }\mathsf{d}t}\)| 2 |
| √ π |
arg e -t 2
d t or \({\small 1-\operatorname{erf}(arg)}\) 1-erf(arg) , is returned.
アンダーフローによる範囲エラーが発生した場合、正しい結果(丸め後)が返されます。
エラー処理
エラーは
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++ documentation
for
erfc
|
|
外部リンク
| Weisstein, Eric W. "Erfc." From MathWorld — A Wolfram Web Resource. |
| Weisstein, Eric W. "Erfc." MathWorld — Wolfram Web リソースより。 |