The erff
function is defined in the <math.h>
header file in C. It takes in a single parameter: a float
value. It then computes the error function of the given argument and returns a value of type float
.
The
erf =
The argument to the
erff
function serves as the upper limit in the integral above.
The error function is widely used in probability and statistics. It integrates the normal distribution and gives the probability that a normally distributed random variable Y (with mean 0 and variance ½) falls into the range [−x, x].
The illustration below shows how erff
function works:
The erff
function is defined as follows:
float erff(float arg);
It takes in a single value of type float
and computes its error function. It then returns the answer of type float
.
The erff
function returns special values for certain arguments:
NAN
, NAN
is returnedThe following code snippet shows how we can use the erff
function:
#include <stdio.h> // Including header file for printf function#include <math.h> // Including header file for erf functionint main (){float param, result;param = 4.0;result = erff(param);printf("erff (%f) = %f\n", param, result);return 0;}
The following code snippet shows how error handling in erff
function works:
#include <stdio.h> // Including header file for printf function#include <math.h> // Including header file for erf functionint main (){printf("erff (%f) = %f\n", 0.0, erff(0.0));return 0;}