C Math erf() Function
Example
Return the error function of different numbers:
printf("%f\n", erf(0));
printf("%f\n", erf(1));
printf("%f", erf(-1));
Definition and Usage
The erf() function returns the value of the error function at x. The result is always between -1 and 1.
The error function is used in statistics, for example to find the chance that a value from a normal distribution (a bell curve) is close to the average.
The erf() function is defined in the <math.h> header file.
Tip: erfc() returns 1 - erf(x).
Syntax
double erf(double x);
There are also versions for float and long double values: erff() and erfl().
Parameter Values
| Parameter | Description |
|---|---|
| x | Required. A number. |
Technical Details
| Returns: | A double value between -1 and 1. |
|---|
Related Pages
Read more about math in our C Math Tutorial.