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
Definiert in Header <cmath>
(1)
float erfc ( float num ) ;

double erfc ( double num ) ;

long double erfc ( long double num ) ;
(bis C++23)
/*floating-point-type*/
erfc ( /*floating-point-type*/ num ) ;
(seit C++23)
(constexpr seit C++26)
float erfcf ( float num ) ;
(2) (seit C++11)
(constexpr seit C++26)
long double erfcl ( long double num ) ;
(3) (seit C++11)
(constexpr seit C++26)
SIMD-Überladung (seit C++26)
Definiert in Header <simd>
template < /*math-floating-point*/ V >

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

erfc ( const V & v_num ) ;
(S) (seit C++26)
Definiert in Header <cmath>
template < class Integer >
double erfc ( Integer num ) ;
(A) (constexpr seit C++26)
1-3) Berechnet die komplementäre Fehlerfunktion von num , also 1.0 - std:: erf ( num ) , jedoch ohne Genauigkeitsverlust für große num . Die Bibliothek stellt Überladungen von std::erfc für alle cv-unqualifizierten Gleitkommatypen als Typ des Parameters bereit. (seit C++23)
S) Die SIMD-Überladung führt eine elementweise std::erfc auf v_num aus.
(Siehe math-floating-point und deduced-simd-t für deren Definitionen.)
(seit C++26)
A) Zusätzliche Überladungen werden für alle Ganzzahltypen bereitgestellt, die als double behandelt werden.
(since C++11)

Inhaltsverzeichnis

Parameter

num - Gleitkomma- oder Ganzzahlwert

Rückgabewert

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.

Wenn ein Bereichsfehler aufgrund von Unterlauf auftritt, wird das korrekte Ergebnis (nach Rundung) zurückgegeben.

Fehlerbehandlung

Fehler werden gemeldet, wie in math_errhandling spezifiziert.

Wenn die Implementierung IEEE-Gleitkommaarithmetik (IEC 60559) unterstützt,

  • Wenn das Argument +∞ ist, wird +0 zurückgegeben.
  • Wenn das Argument -∞ ist, wird 2 zurückgegeben.
  • Wenn das Argument NaN ist, wird NaN zurückgegeben.

Hinweise

Für den IEEE-kompatiblen Typ double ist ein Unterlauf garantiert, wenn num > 26.55 .

Die zusätzlichen Überladungen müssen nicht exakt wie (A) bereitgestellt werden. Sie müssen lediglich sicherstellen, dass für ihr Argument num vom Ganzzahltyp std :: erfc ( num ) dieselbe Wirkung hat wie std :: erfc ( static_cast < double > ( num ) ) .

Beispiel

#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';
}

Ausgabe:

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

Siehe auch

(C++11) (C++11) (C++11)
Fehlerfunktion
(Funktion)

Externe Links

Weisstein, Eric W. "Erfc." Von MathWorld — Eine Wolfram Web Resource.