C++ cmath erf() Function
Example
Return the error function of different numbers:
cout << erf(0) << "\n";
cout << erf(1) << "\n";
cout << 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 <cmath> header file.
Tip: erfc() returns 1 - erf(x).
Syntax
erf(double x)
The function also works with float and long double values. Then it returns a value of the same type.
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 Math Tutorial.