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 set errno. zero. zilch. nada. do not go checking errno and 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms