Namespaces
Variants
Views
Actions

erf

From cppreference.com
< c‎ | numeric‎ | math
 
 
 
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)(C99)(C99)
Exponential functions
(C99)
(C99)
(C99)
(C99)
Power functions
(C99)
(C99)
Trigonometric and hyperbolic functions
(C99)
(C99)
(C99)
Error and gamma functions
erf
(C99)
(C99)
(C99)
(C99)
Nearest integer floating point operations
(C99)(C99)(C99)
(C99)
(C99)(C99)(C99)
Floating point manipulation functions
(C99)(C99)
(C99)
(C99)
Classification
(C99)
(C99)
(C99)
Macro constants
 
Defined in header <math.h>
float       erff( float arg );
(since C99)
double      erf( double arg );
(since C99)
long double erfl( long double arg );
(since C99)

Computes the error function of arg.

Contents

[edit] Parameters

arg - floating point value

[edit] Return value

The value of the error function of arg, that is
2
π
arg
0
e-t2
dt
.

[edit] Example

#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
 
int main()
{
    printf("erf(0.5)       = %f\n",    erf(0.5));
    printf("erfc(0.5)      = %f\n",    erfc(0.5));   /* complement of erf */
    printf("erf(+0.0)      = %+.1f\n", erf(+0.0));
    printf("erf(-0.0)      = %+.1f\n", erf(-0.0));
    printf("erf(+INFINITY) = %+.1f\n", erf(+INFINITY));
    printf("erf(-INFINITY) = %+.1f\n", erf(-INFINITY));
    printf("erf(NAN)       = %f\n",    erf(NAN));
    printf("\n");
 
    return 0;
}

Possible output:

erf(0.5)       = 0.520500
erfc(0.5)      = 0.479500
erf(+0.0)      = +0.0
erf(-0.0)      = -0.0
erf(+INFINITY) = +1.0
erf(-INFINITY) = -1.0
erf(NAN)       = nan

[edit] See also

(C99)
complementary error function
(function) [edit]

[edit] External links

Weisstein, Eric W. "Erf." From MathWorld--A Wolfram Web Resource.