expm1(3)
β¨ expm1(3) β exponential minus 1 β¨
okay bestie, welcome to expm1(3) π this is a page from the Library Functions Manual, and we're about to make the whole "subtract 1 from an exponential" situation make sense. no cap.
π«Ά NAME π«Ά
expm1, expm1f, expm1l β exponential minus 1
π LIBRARY π
Math library (libm, -lm) β yeah you gotta link it, that's just the vibe.
πΈ SYNOPSIS πΈ
#include <math.h>
double expm1(double x);
float expm1f(float x);
long double expm1l(long double x);
π§ Feature Test Macro Requirements for glibc π§
(peep feature_test_macros(7) if you want the lore)
expm1():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| _XOPEN_SOURCE >= 500
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
expm1f(), expm1l():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
π DESCRIPTION π
So these functions return a value equivalent to
exp(x) - 1
but here's the iconic part, the reason she exists: the result gets computed in a way that stays accurate even when x is near zero. that's the case where plain old exp(x) - 1 would be a whole mess, because you'd be subtracting two numbers that are nearly equal and losing all your precision. it's giving catastrophic cancellation. not on her watch. π₯
π RETURN VALUE π
On success, these functions return exp(x) - 1. periodt.
- If
xis a NaN, a NaN is returned. (NaN in, NaN out, the circle of life π¦) - If
xis+0(-0),+0(-0) is returned. - If
xis positive infinity, positive infinity is returned. π - If
xis negative infinity,-1is returned. - If the result overflows, a range error occurs, and the functions return
-HUGE_VAL,-HUGE_VALF, or-HUGE_VALL, respectively.
π ERRORS π
Go read math_error(7) if you wanna know how to figure out whether an error even happened when you called one of these. it's all in there.
The following errors can occur:
- Range error, overflow β
errnois set toERANGE(but see BUGS, bestie, there's always a BUGS section). An overflow floating-point exception (FE_OVERFLOW) is raised.
π ATTRIBUTES π
for what all these terms even mean, see attributes(7).
- Interface:
expm1(),expm1f(),expm1l() - Attribute: Thread safety
- Value:
MT-Safe
thread safe, no drama, we love her for that π«Ά
β STANDARDS β
C11, POSIX.1-2008.
π¦ HISTORY π¦
C99, POSIX.1-2001. BSD.
ancient. legendary. still standing. π
π BUGS π
okay so the old versions were lowkey messy, we have receipts:
- Before glibc 2.17, on certain architectures (e.g., x86, but not x86_64)
expm1()raised a bogus underflow floating-point exception for some large negativexvalues (where the function result approaches-1). π - Before approximately glibc 2.11,
expm1()raised a bogus invalid floating-point exception in addition to the expected overflow exception, and returned a NaN instead of positive infinity, for some large positivexvalues. π - Before glibc 2.11, the glibc implementation did not set
errnotoERANGEwhen a range error occurred.
all fixed now, glow-up complete, but iykyk.
π SEE ALSO π
that's the whole page bestie, you're officially an expm1 girlie π sending you good vibes and accurate floating-point results, mwah π this was Linux man-pages 6.20, dated 2026-02-08, and the page itself is expm1(3) β go forth and compute β¨
π¦ 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 1995, James R. Van Zandt <jrv@vanzandt.mv.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms