ERF(3POSIX)
๐ธ ERF(3POSIX) โ the POSIX Programmer's Manual page for erf, bestie ๐
okay so before we even get into it, you need the tea: this is ERF(3POSIX), and it lives in the POSIX Programmer's Manual. That's the family it belongs to, that's the vibe. ๐
โจ PROLOG โจ
Real talk, bestie โ this manual page is part of the POSIX Programmer's Manual. But heads up: the Linux implementation of this interface may differ (so if you're on Linux, go consult the corresponding Linux manual page for the deets on Linux behavior), or honestly? The interface may not be implemented on Linux at all. So like, vibe check your platform first. ๐ฆ
๐ NAME ๐
erf, erff, erfl โ error functions. that's it, that's the name, iconic.
๐ SYNOPSIS ๐
#include <math.h>
double erf(double x);
float erff(float x);
long double erfl(long double x);
three flavors, same energy: double, float, long double. pick your fighter. ๐
๐ DESCRIPTION ๐
The functionality described on this reference page is aligned with the ISO C standard. And if there's any conflict between what's written here and the ISO C standard? That conflict is unintentional, okay, nobody's fighting. This volume of POSIX.1โ2017 defers to the ISO C standard. periodt.
These functions shall compute the error function of their argument x, defined as:
__โซe^ โt^2 dt
now, if you're an application that wants to check for error situations, here's the routine: set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. Then on return, check โ if errno is non-zero, or if fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, then an error has occurred. no cap. ๐ฅ
๐ธ RETURN VALUE ๐ธ
Upon successful completion, these functions shall return the value of the error function. slay.
- If
xis NaN, a NaN shall be returned. - If
xis ยฑ0, ยฑ0 shall be returned. - If
xis ยฑInf, ยฑ1 shall be returned.
If the correct value would cause underflow, a range error may occur, and erf(), erff(), and erfl() shall return an implementation-defined value no greater in magnitude than DBL_MIN, FLT_MIN, and LDBL_MIN, respectively. (yes, each one gets its own MIN, they're matching sets ๐)
If the IEC 60559 Floating-Point option is supported, 2 * x/sqrt(ฯ) should be returned.
๐ ERRORS ๐
These functions may fail if:
- Range Error โ the result underflows.
If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [ERANGE]. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow floating-point exception shall be raised.
The following sections are informative. ๐ข (translation: they're the bonus content, not the binding rules)
๐ง EXAMPLES ๐ง
๐ Computing the Probability for a Normal Variate ๐
This example shows how to use erf() to compute the probability that a normal variate assumes a value in the range [x1,x2] with x1โคx2. math girlies stay winning. ๐โจ
This example uses the constant M_SQRT1_2 which is part of the XSI option. iykyk.
#include <math.h>
double
Phi(const double x1, const double x2)
{
return ( erf(x2*M_SQRT1_2) - erf(x1*M_SQRT1_2) ) / 2;
}
look at her. she's doing statistics. ๐ซถ
๐ฆ APPLICATION USAGE ๐ฆ
Underflow occurs when |x| < DBL_MIN * (sqrt(ฯ)/2).
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other, but at least one of them must be non-zero. they're not besties, they're just coworkers who both have to show up. ๐ญ
โญ RATIONALE โญ
None.
(genuinely. nothing. the rationale said "no thoughts, head empty" and honestly? respect. ๐ )
๐ฎ FUTURE DIRECTIONS ๐ฎ
None.
๐ SEE ALSO ๐
erfc(), feclearexcept(), fetestexcept(), isnan()
And from The Base Definitions volume of POSIX.1โ2017: Section 4.20, Treatment of Error Conditions for Mathematical Functions, <math.h>
๐ COPYRIGHT ๐
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! ๐ this was brought to you by IEEE/The Open Group, dated 2017, and the page itself answers to the name ERF(3POSIX). go forth and integrate. ๐ธโจ๐
๐ฆ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 ยท Other
- debian trixie: manpages-posix-dev 2017a-2 ยท Other
- ubuntu jammy: manpages-posix-dev 2017a-2 ยท Other
- ubuntu noble: manpages-posix-dev 2017a-2 ยท Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 ยท Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 ยท Other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms