1ERF(3P)                    POSIX Programmer's Manual                   ERF(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11       delim $$
12

NAME

14       erf, erff, erfl — error functions
15

SYNOPSIS

17       #include <math.h>
18
19       double erf(double x);
20       float erff(float x);
21       long double erfl(long double x);
22

DESCRIPTION

24       The functionality described on this reference page is aligned with  the
25       ISO C  standard.  Any  conflict between the requirements described here
26       and the ISO C standard is unintentional. This  volume  of  POSIX.1‐2008
27       defers to the ISO C standard.
28
29       These  functions  shall compute the error function of their argument x,
30       defined as:
31
32              ${2 over sqrt pi} int from 0 to x e"^" " "{- t"^" 2" "} dt$
33
34       An application wishing to check for error situations should  set  errno
35       to  zero  and  call  feclearexcept(FE_ALL_EXCEPT)  before calling these
36       functions. On return, if errno is non-zero or fetestexcept(FE_INVALID |
37       FE_DIVBYZERO  |  FE_OVERFLOW  | FE_UNDERFLOW) is non-zero, an error has
38       occurred.
39

RETURN VALUE

41       Upon successful completion, these functions shall return the  value  of
42       the error function.
43
44       If x is NaN, a NaN shall be returned.
45
46       If x is ±0, ±0 shall be returned.
47
48       If x is ±Inf, ±1 shall be returned.
49
50       If  the  correct  value would cause underflow, a range error may occur,
51       and erf(), erff(), and erfl() shall  return  an  implementation-defined
52       value  no  greater  in  magnitude  than DBL_MIN, FLT_MIN, and LDBL_MIN,
53       respectively.
54
55       If the IEC 60559 Floating-Point option  is  supported,  2  *  x/sqrt(π)
56       should be returned.
57

ERRORS

59       These functions may fail if:
60
61       Range Error The result underflows.
62
63                   If  the  integer expression (math_errhandling & MATH_ERRNO)
64                   is non-zero, then errno shall be set to [ERANGE].   If  the
65                   integer  expression  (math_errhandling & MATH_ERREXCEPT) is
66                   non-zero, then the underflow floating-point exception shall
67                   be raised.
68
69       The following sections are informative.
70

EXAMPLES

72   Computing the Probability for a Normal Variate
73       This  example  shows how to use erf() to compute the probability that a
74       normal variate assumes a value in the range [x1,x2] with x1≤x2.
75
76       This example uses the constant M_SQRT1_2  which  is  part  of  the  XSI
77       option.
78
79           #include <math.h>
80
81           double
82           Phi(const double x1, const double x2)
83           {
84               return ( erf(x2*M_SQRT1_2) − erf(x1*M_SQRT1_2) ) / 2;
85           }
86

APPLICATION USAGE

88       Underflow occurs when |x| < DBL_MIN * (sqrt(π)/2).
89
90       On   error,   the   expressions  (math_errhandling  &  MATH_ERRNO)  and
91       (math_errhandling & MATH_ERREXCEPT) are independent of each other,  but
92       at least one of them must be non-zero.
93

RATIONALE

95       None.
96

FUTURE DIRECTIONS

98       None.
99

SEE ALSO

101       erfc(), feclearexcept(), fetestexcept(), isnan()
102
103       The Base Definitions volume of POSIX.1‐2008, Section 4.19, Treatment of
104       Error Conditions for Mathematical Functions, <math.h>
105
107       Portions of this text are reprinted and reproduced in  electronic  form
108       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
109       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
110       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
111       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
112       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
113       event of any discrepancy between this version and the original IEEE and
114       The  Open Group Standard, the original IEEE and The Open Group Standard
115       is the referee document. The original Standard can be  obtained  online
116       at http://www.unix.org/online.html .
117
118       Any  typographical  or  formatting  errors that appear in this page are
119       most likely to have been introduced during the conversion of the source
120       files  to  man page format. To report such errors, see https://www.ker
121       nel.org/doc/man-pages/reporting_bugs.html .
122
123
124
125IEEE/The Open Group                  2013                              ERF(3P)
Impressum