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 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 표준 (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)
|
오차 함수를 계산함
(함수) |
|
C++ documentation
for
erfc
|
|
외부 링크
| Weisstein, Eric W. "Erfc." MathWorld — 울프램 웹 리소스에서. |