erf(3)
π erf(3) β the error function, bestie edition π
okay so this is a page from the Library Functions Manual, and it's about erf, erff, and erfl. yes it's math. no you don't have to be scared. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
erf, erff, erfl β the error function. that's it, that's the whole vibe. not an error, not your error, THE error function. very demure, very mathematical π
π LIBRARY π
Math library, aka libm, which you link with -lm. don't forget the -lm or you'll be sad and confused, and not in a cute way π
πΈ SYNOPSIS πΈ
#include <math.h>
double erf(double x);
float erff(float x);
long double erfl(long double x);
three little functions, three different levels of precision, all iconic in their own way β¨
π Feature Test Macro Requirements for glibc (see feature_test_macros(7)) π
so like, glibc is particular about how you ask for these. you gotta declare your intentions, no cap.
erf():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
erff(), erfl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
see how erff() and erfl() don't need _XOPEN_SOURCE? yeah. they're built different. noted. π
π¦ DESCRIPTION π¦
these functions return the error function of x, defined as:
erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(-t*t) dt
it's giving calculus. it's giving integral from 0 to x. it's giving exp(-t*t) dt. slay π
π RETURN VALUE π
on success, these functions return the value of the error function of x, and that value lives in the range [-1, 1]. cozy little range, we love that for it π
- if x is a NaN, a NaN is returned. (NaN in, NaN out, the circle of life π¦)
- if x is
+0(-0),+0(-0) is returned. - if x is positive infinity (negative infinity),
+1(-1) is returned. - if x is subnormal, a range error occurs, and the return value is
2*x/sqrt(pi).
π ERRORS π
see math_error(7) for the whole lore on figuring out whether an error even happened when you called these functions. the tea is in there β
these are the errors that can occur:
Range error: result underflow (x is subnormal) : an underflow floating-point exception (FE_UNDERFLOW) is raised. not me getting an exception π
β οΈ important: these functions do not seterrno. zero. zilch. nada. do not go checkingerrnoand expecting an answer, bestie, it's not coming π
π§ ATTRIBUTES π§
for an explanation of the terms used in this section, see attributes(7). the table in the original is very official, so here it is in bullet form, still 100% factual:
- Interface:
erf(),erff(),erfl()β Attribute: Thread safety β Value:MT-Safe
MT-Safe. she's safe to call from multiple threads. main character energy AND team player energy π₯
β STANDARDS β
C11, POSIX.1-2008. certified, standardized, official. periodt.
πΈ HISTORY πΈ
C99, POSIX.1-2001.
also: the variant returning double β that's erf() β also conforms to SVr4, 4.3BSD. ancient lineage, honestly kind of iconic π
π SEE ALSO π
go read those next, bestie, they're the extended universe π«Ά
and that's the page!! this was Linux man-pages 6.20, dated 2026-02-08, brought to you by the letter erf(3) π no cap, you understood all of it. go forth and compute your error functions responsibly β¨π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms