6.11.41 erf Function
Calculates the error function of the argument.
Include
<math.h>
Prototype
double erf(double x);
Argument
x
- upper limit of summation
Return Value
Returns the error function of the argument, being the summation of the error function from zero to the argument value.
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <math.h>
#include <stdio.h>
int main(void)
{
double x, y;
x = 0.5;
y = erf(x);
printf("The summation of the error function from 0 to %f is %f\n", x, y);
x = -0.75;
y = erf(x);
printf("The summation of the error function from 0 to %f is %f\n", x, y);
}
Example Output
The summation of the error function from 0 to 0.500000 is 0.520500
The summation of the error function from 0 to -0.750000 is -0.711156