erf() - erfc() — 誤差関数の計算

フォーマット

#include <math.h>
double erf(double x);
double erfc(double x);

言語レベル

ANSI

スレッド・セーフ

はい

説明

erf() 関数は、以下の誤差関数を計算します。

erf () 関数

erfc() 関数は 1.0 - erf(x) の値を計算します。 x の値が大きい場合は、erfc() 関数を erf() の代わりに使用します。

戻り値

erf() 関数は、誤差関数を表す double 値を戻します。 erfc() 関数は、1.0 - erf を表す double 値を戻します。

次の例は erf()erfc() を使用して 2 つの数値の誤差関数を計算します。
#include <stdio.h>
#include <math.h>
 
double smallx, largex, value;
 
int main(void)
{
   smallx = 0.1;
   largex = 10.0;
 
   value = erf(smallx);         /* value = 0.112463 */
   printf("Error value for 0.1: %lf¥n", value);
 
   value = erfc(largex);        /* value = 2.088488e-45 */
   printf("Error value for 10.0: %le¥n", value);
}
 
/*****************  Output should be similar to:  *****************
 
Error value for 0.1: 0.112463
Error value for 10.0: 2.088488e-45
*/