- cmath[meta header]
- std[meta namespace]
- function[meta id-type]
- cpp11[meta cpp]
- [mathjax enable]
namespace std {
float erfc(float x); // (1) C++11からC++20まで
double erfc(double x); // (2) C++11からC++20まで
long double erfc(long double x); // (3) C++11からC++20まで
floating-point-type
erfc(floating-point-type x); // (4) C++23
constexpr floating-point-type
erfc(floating-point-type x); // (4) C++26
double
erfc(Integral x); // (5) C++11
constexpr double
erfc(Integral x); // (5) C++26
float
erfcf(float x); // (6) C++17
constexpr float
erfcf(float x); // (6) C++26
long double
erfcl(long double x); // (7) C++17
constexpr long double
erfcl(long double x); // (7) C++26
}
- Integral[italic]
算術型の相補誤差関数 (complementary error function) を求める。
- (1) :
float
に対するオーバーロード - (2) :
double
に対するオーバーロード - (3) :
long double
に対するオーバーロード - (4) : 浮動小数点数型に対するオーバーロード
- (5) : 整数型に対するオーバーロード (
double
にキャストして計算される) - (6) :
float
型規定 - (7) :
long double
型規定
引数 x
の相補誤差関数を返す。
x
が大き過ぎる場合はアンダーフローエラーとなる。
- $$ f(x) = \mathrm{erfc}~x \equiv 1 - \mathrm{erf}~x \equiv \frac{2}{\sqrt{\pi}} \int_x^\infty e^{-t^2} dt $$
- C++11 以降では、処理系が IEC 60559 に準拠している場合(
std::numeric_limits
<T>::
is_iec559
() != false
)、以下の規定が追加される。x = -∞
の場合、戻り値は2
となる。x = +∞
の場合、戻り値は+0
となる。
- C++23では、(1)、(2)、(3)が(4)に統合され、拡張浮動小数点数型を含む浮動小数点数型へのオーバーロードとして定義された
#include <cmath>
#include <iostream>
#include <limits>
int main() {
std::cout << std::fixed;
std::cout << "erfc(-∞) = " << std::erfc(-std::numeric_limits<double>::infinity()) << std::endl;
std::cout << "erfc(0) = " << std::erfc(0.0) << std::endl;
std::cout << "erfc(1) = " << std::erfc(1.0) << std::endl;
std::cout << "erfc(+∞) = " << std::erfc(std::numeric_limits<double>::infinity()) << std::endl;
}
- std::erfc[color ff0000]
- std::fixed[link ../ios/fixed.md]
- infinity()[link ../limits/numeric_limits/infinity.md]
erfc(-∞) = 2.000000
erfc(0) = 1.000000
erfc(1) = 0.157299
erfc(+∞) = 0.000000
- C++11
- Clang: 3.0 [mark verified]
- GCC: 4.3.6 [mark verified]
- ICC: ??
- Visual C++: ??
特定の環境では、早期に constexpr
対応されている場合がある:
- GCC 4.6.1 以上
- P1467R9 Extended floating-point types and standard names
- C++23で導入された拡張浮動小数点数型への対応として、
float
、double
、long double
のオーバーロードをfloating-point-type
のオーバーロードに統合し、拡張浮動小数点数型も扱えるようにした
- C++23で導入された拡張浮動小数点数型への対応として、
- P1383R2 More constexpr for
<cmath>
and<complex>
- C++26で
constexpr
対応した
- C++26で