Namespaces
Variants

std:: erfc, std:: erfcf, std:: erfcl

From cppreference.net
Common mathematical functions
Nearest integer floating point operations
(C++11)
(C++11)
(C++11) (C++11) (C++11)
Floating point manipulation functions
(C++11) (C++11)
(C++11)
(C++11)
Classification and comparison
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Types
(C++11)
(C++11)
(C++11)
Macro constants
헤더 파일에 정의됨 <cmath>
(1)
float erfc ( float num ) ;

double erfc ( double num ) ;

long double erfc ( long double num ) ;
(C++23 이전)
/*floating-point-type*/
erfc ( /*floating-point-type*/ num ) ;
(C++23 이후)
(C++26부터 constexpr)
float erfcf ( float num ) ;
(2) (C++11 이후)
(C++26부터 constexpr)
long double erfcl ( long double num ) ;
(3) (C++11 이후)
(C++26부터 constexpr)
SIMD 오버로드 (C++26 이후)
헤더 파일에 정의됨 <simd>
template < /*math-floating-point*/ V >

constexpr /*deduced-simd-t*/ < V >

erfc ( const V & v_num ) ;
(S) (C++26 이후)
추가 오버로드 (C++11 이후)
헤더 파일에 정의됨 <cmath>
template < class Integer >
double erfc ( Integer num ) ;
(A) (C++26부터 constexpr)
1-3) num 여오차 함수 를 계산합니다. 즉, 1.0 - std:: erf ( num ) 이지만, 큰 num 값에 대해 정밀도 손실 없이 계산됩니다. 라이브러리는 매개변수 타입으로 모든 cv-한정되지 않은 부동소수점 타입에 대한 std::erfc 의 오버로드를 제공합니다. (C++23부터)
S) SIMD 오버로드는 v_num 에 대해 요소별(element-wise) std::erfc 를 수행합니다.
(정의는 math-floating-point deduced-simd-t 를 참조하십시오.)
(C++26부터)
A) 모든 정수 타입에 대해 추가 오버로드가 제공되며, 이들은 double 로 처리됩니다.
(since C++11)

목차

매개변수

num - 부동 소수점 또는 정수 값

반환값

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

num
e -t 2
d t
or 1-erf(num) , is returned.

언더플로우로 인해 범위 오류가 발생하면, 올바른 결과(반올림 후)가 반환됩니다.

오류 처리

오류는 math_errhandling 에 명시된 대로 보고됩니다.

구현이 IEEE 부동 소수점 연산(IEC 60559)을 지원하는 경우,

  • 인수가 +∞인 경우, +0이 반환됩니다.
  • 인수가 -∞인 경우, 2가 반환됩니다.
  • 인수가 NaN인 경우, NaN이 반환됩니다.

참고 사항

IEEE 호환 타입 double 의 경우, num > 26.55 이면 언더플로우가 보장됩니다.

추가 오버로드는 반드시 (A) 와 정확히 동일하게 제공될 필요가 없습니다. 정수형 인수 num 에 대해 std :: erfc ( num ) std :: erfc ( static_cast < double > ( num ) ) 와 동일한 효과를 가지도록 보장하기에 충분하기만 하면 됩니다.

예제

#include <cmath>
#include <iomanip>
#include <iostream>
double normalCDF(double x) // Phi(-∞, x) aka N(x)
{
    return std::erfc(-x / std::sqrt(2)) / 2;
}
int main()
{
    std::cout << "normal cumulative distribution function:\n"
              << std::fixed << std::setprecision(2);
    for (double n = 0; n < 1; n += 0.1)
        std::cout << "normalCDF(" << n << ") = " << 100 * normalCDF(n) << "%\n";
    std::cout << "special values:\n"
              << "erfc(-Inf) = " << std::erfc(-INFINITY) << '\n'
              << "erfc(Inf) = " << std::erfc(INFINITY) << '\n';
}

출력:

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.00
erfc(Inf) = 0.00

참고 항목

(C++11) (C++11) (C++11)
오차 함수
(함수)
C 문서 for erfc

외부 링크

Weisstein, Eric W. "Erfc." MathWorld — Wolfram 웹 리소스에서.