Namespaces
Variants

erfc, erfcf, erfcl

From cppreference.net
< c ‎ | numeric ‎ | math
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99) (C99) (C99) (C23)
Maximum/minimum operations
Exponential functions
Power functions
Trigonometric and hyperbolic functions
Nearest integer floating-point
(C99) (C99) (C99)
(C23) (C23) (C23) (C23)
Floating-point manipulation
Narrowing operations
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
Quantum and quantum exponent
Decimal re-encoding functions
Total order and payload functions
Classification
Error and gamma functions
(C99)
erfc
(C99)
(C99)
(C99)
Types
Macro constants
Special floating-point values
Arguments and return values
Error handling
Fast operation indicators
ヘッダーで定義 <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以降)
1-3) 引数 arg 相補誤差関数 を計算します。すなわち 1.0 - erf ( arg ) ですが、大きな arg に対しても精度の低下がありません。
4) 型総称マクロ: arg long double 型の場合、 erfcl が呼び出される。それ以外の場合、 arg が整数型または double 型の場合、 erfc が呼び出される。それ以外の場合、 erfcf が呼び出される。

目次

パラメータ

arg - 浮動小数点値

戻り値

If no errors occur, value of the complementary error function of arg , that is
2
π

arg
e -t 2
d t
or 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)
誤差関数を計算する
(関数)

外部リンク

Weisstein, Eric W. "Erfc." From MathWorld — A Wolfram Web Resource.
以下は日本語訳です:
Weisstein, Eric W. "Erfc." MathWorld — Wolfram Web リソースより。
変更点: - "From MathWorld — A Wolfram Web Resource." → "MathWorld — Wolfram Web リソースより。" - HTMLタグ、属性、Erfc(C++用語)は翻訳せず保持