C <math.h> - erf() Function
The C <math.h> erf() function returns the error function of the argument. The error function of x is defined as:
Error functions usually occur in probability, statistics and partial differential equation describing diffusion.
Syntax
double erf (double x); float erff (float x); long double erfl (long double x);
Parameters
x |
Specify the value. |
Return Value
Returns the error function of the argument.
Example:
In the example below, erf() function returns the error function of the given value.
#include <stdio.h> #include <math.h> int main (){ printf("%lf\n", erf(0)); printf("%lf\n", erf(1)); printf("%lf\n", erf(2)); printf("%lf\n", erf(-1)); printf("%lf\n", erf(-2)); return 0; }
The output of the above code will be:
0.000000 0.842701 0.995322 -0.842701 -0.995322
❮ C <math.h> Library