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
Défini dans l'en-tête <math.h>
float erfcf ( float arg ) ;
(1) (depuis C99)
double erfc ( double arg ) ;
(2) (depuis C99)
long double erfcl ( long double arg ) ;
(3) (depuis C99)
Défini dans l'en-tête <tgmath.h>
#define erfc( arg )
(4) (depuis C99)
1-3) Calcule la fonction d'erreur complémentaire de arg , c'est-à-dire 1.0 - erf ( arg ) , mais sans perte de précision pour les grandes valeurs de arg .
4) Macro générique de type : Si arg a le type long double , erfcl est appelé. Sinon, si arg a un type entier ou le type double , erfc est appelé. Sinon, erfcf est appelé.

Table des matières

Paramètres

arg - valeur en virgule flottante

Valeur de retour

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.

Si une erreur de plage se produit en raison d'un dépassement inférieur, le résultat correct (après arrondi) est retourné.

Gestion des erreurs

Les erreurs sont signalées comme spécifié dans math_errhandling .

Si l'implémentation prend en charge l'arithmétique à virgule flottante IEEE (IEC 60559),

  • Si l'argument est +∞, +0 est retourné.
  • Si l'argument est -∞, 2 est retourné.
  • Si l'argument est NaN, NaN est retourné.

Notes

Pour le type compatible IEEE double , un dépassement inférieur est garanti si arg > 26.55 .

Exemple

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

Sortie :

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

Références

  • Norme C23 (ISO/CEI 9899:2024) :
  • 7.12.8.2 Les fonctions erfc (p : 249-250)
  • 7.25 Mathématiques génériques <tgmath.h> (p : 373-375)
  • F.10.5.2 Les fonctions erfc (p : 525)
  • Norme C17 (ISO/CEI 9899:2018) :
  • 7.12.8.2 Les fonctions erfc (p : 249-250)
  • 7.25 Mathématiques génériques de type <tgmath.h> (p : 373-375)
  • F.10.5.2 Les fonctions erfc (p : 525)
  • Norme C11 (ISO/IEC 9899:2011) :
  • 7.12.8.2 Les fonctions erfc (p : 249-250)
  • 7.25 Mathématiques génériques de type <tgmath.h> (p : 373-375)
  • F.10.5.2 Les fonctions erfc (p : 525)
  • Norme C99 (ISO/CEI 9899:1999) :
  • 7.12.8.2 Les fonctions erfc (p : 230)
  • 7.22 Mathématiques génériques de type <tgmath.h> (p : 335-337)
  • F.9.5.2 Les fonctions erfc (p : 462)

Voir aussi

(C99) (C99) (C99)
calcule la fonction d'erreur
(fonction)

Liens externes

Weisstein, Eric W. "Erfc." De MathWorld — Une ressource web Wolfram.