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
Definido en el encabezado <math.h>
float erfcf ( float arg ) ;
(1) (desde C99)
double erfc ( double arg ) ;
(2) (desde C99)
long double erfcl ( long double arg ) ;
(3) (desde C99)
Definido en el encabezado <tgmath.h>
#define erfc( arg )
(4) (desde C99)
1-3) Calcula la función de error complementaria de arg , es decir 1.0 - erf ( arg ) , pero sin pérdida de precisión para valores grandes de arg .
4) Macro genérico de tipos: Si arg tiene tipo long double , erfcl es llamado. De lo contrario, si arg tiene tipo entero o el tipo double , erfc es llamado. De lo contrario, erfcf es llamado.

Contenidos

Parámetros

arg - valor de punto flotante

Valor de retorno

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 ocurre un error de rango debido a desbordamiento inferior, se devuelve el resultado correcto (después del redondeo).

Manejo de errores

Los errores se reportan como se especifica en math_errhandling .

Si la implementación soporta aritmética de punto flotante IEEE (IEC 60559),

  • Si el argumento es +∞, se devuelve +0.
  • Si el argumento es -∞, se devuelve 2.
  • Si el argumento es NaN, se devuelve NaN.

Notas

Para el tipo compatible con IEEE double , se garantiza el subdesbordamiento si arg > 26.55 .

Ejemplo

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

Salida:

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

Referencias

  • Estándar C23 (ISO/IEC 9899:2024):
  • 7.12.8.2 Las funciones erfc (p: 249-250)
  • 7.25 Matemáticas genéricas de tipos <tgmath.h> (p: 373-375)
  • F.10.5.2 Las funciones erfc (p: 525)
  • Estándar C17 (ISO/IEC 9899:2018):
  • 7.12.8.2 Las funciones erfc (p: 249-250)
  • 7.25 Matemáticas genéricas de tipos <tgmath.h> (p: 373-375)
  • F.10.5.2 Las funciones erfc (p: 525)
  • Estándar C11 (ISO/IEC 9899:2011):
  • 7.12.8.2 Las funciones erfc (p: 249-250)
  • 7.25 Matemáticas genéricas de tipos <tgmath.h> (p: 373-375)
  • F.10.5.2 Las funciones erfc (p: 525)
  • Estándar C99 (ISO/IEC 9899:1999):
  • 7.12.8.2 Las funciones erfc (p: 230)
  • 7.22 Matemáticas genéricas de tipo <tgmath.h> (p: 335-337)
  • F.9.5.2 Las funciones erfc (p: 462)

Véase también

(C99) (C99) (C99)
calcula la función de error
(función)

Enlaces externos

Weisstein, Eric W. "Erfc." De MathWorld — Un recurso web de Wolfram.