Namespaces
Variants

erfc, erfcf, erfcl

From cppreference.net
< c ‎ | numeric ‎ | math
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99) (C99) (C99) (C23)
Maximum/minimum operations
Exponential functions
Power functions
Trigonometric and hyperbolic functions
Nearest integer floating-point
(C99) (C99) (C99)
(C23) (C23) (C23) (C23)
Floating-point manipulation
Narrowing operations
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
Quantum and quantum exponent
Decimal re-encoding functions
Total order and payload functions
Classification
Error and gamma functions
(C99)
erfc
(C99)
(C99)
(C99)
Types
Macro constants
Special floating-point values
Arguments and return values
Error handling
Fast operation indicators
Definiert im Header <math.h>
float erfcf ( float arg ) ;
(1) (seit C99)
double erfc ( double arg ) ;
(2) (seit C99)
long double erfcl ( long double arg ) ;
(3) (seit C99)
Definiert im Header <tgmath.h>
#define erfc( arg )
(4) (seit C99)
1-3) Berechnet die komplementäre Fehlerfunktion von arg , also 1.0 - erf ( arg ) , jedoch ohne Genauigkeitsverlust für große arg -Werte.
4) Typgenerisches Makro: Wenn arg den Typ long double hat, wird erfcl aufgerufen. Andernfalls, wenn arg einen Ganzzahltyp oder den Typ double hat, wird erfc aufgerufen. Andernfalls wird erfcf aufgerufen.

Inhaltsverzeichnis

Parameter

arg - Gleitkommawert

Rückgabewert

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

arg
e -t 2
d t
or 1-erf(arg) , 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 festgelegt.

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 arg > 26.55 .

Beispiel

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

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.000000
erfc(Inf) = 0.000000

Referenzen

  • C23-Standard (ISO/IEC 9899:2024):
  • 7.12.8.2 Die erfc-Funktionen (S: 249-250)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S: 373-375)
  • F.10.5.2 Die erfc-Funktionen (S: 525)
  • C17-Standard (ISO/IEC 9899:2018):
  • 7.12.8.2 Die erfc-Funktionen (S. 249-250)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S. 373-375)
  • F.10.5.2 Die erfc-Funktionen (S. 525)
  • C11-Standard (ISO/IEC 9899:2011):
  • 7.12.8.2 Die erfc-Funktionen (S: 249-250)
  • 7.25 Typgenerische Mathematik <tgmath.h> (S: 373-375)
  • F.10.5.2 Die erfc-Funktionen (S: 525)
  • C99-Standard (ISO/IEC 9899:1999):
  • 7.12.8.2 Die erfc-Funktionen (S. 230)
  • 7.22 Typgenerische Mathematik <tgmath.h> (S. 335-337)
  • F.9.5.2 Die erfc-Funktionen (S. 462)

Siehe auch

(C99) (C99) (C99)
berechnet die Fehlerfunktion
(Funktion)

Externe Links

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