log1p(3)
π log1p(3) β bestie's guide to the log of 1+x π
okay so this is the manual page for log1p, from the Library Functions Manual, and honestly? she's a baddie. let me put you on. π«Ά
β¨ NAME β¨
log1p, log1pf, log1pl β logarithm of 1 plus argument. that's it, that's the girl. π
π LIBRARY π
Math library (libm, -lm). yes bestie you have to link her in, she does not come free. π
πΈ SYNOPSIS πΈ
#include <math.h>
double log1p(double x);
float log1pf(float x);
long double log1pl(long double x);
π¦ Feature Test Macro Requirements for glibc (see feature_test_macros(7)) π¦
log1p():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| _XOPEN_SOURCE >= 500
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
log1pf(), log1pl():
_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
|| /* Since glibc 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
like, define the right macro or she will simply not speak to you, no cap. π
π DESCRIPTION π
these functions return a value equivalent to
log(1 + x)
and the way they do it is accurate even when x is super close to zero. that's the whole point of her existence fr fr β naive log(1 + x) loses precision down there and it's giving cancellation, but log1p ate. πβ¨
π₯ RETURN VALUE π₯
- On success, these functions return the natural logarithm of
(1 + x). slay. - If
xis a NaN, a NaN is returned. she matches your energy. - If
xis positive infinity, positive infinity is returned. iconic behavior, honestly. - If
xis-1, a pole error occurs, and the functions return-HUGE_VAL,-HUGE_VALF, or-HUGE_VALL, respectively. π - If
xis less than-1(including negative infinity), a domain error occurs, and a NaN (not a number) is returned. she said "not today."
π ERRORS π
see math_error(7) for info on how to figure out whether an error has even happened when you call these functions. iykyk.
the following errors can occur:
- Domain error:
xis less than-1.errnois set toEDOM(but see BUGS, bestie, it's messy down there). An invalid floating-point exception (FE_INVALID) is raised. - Pole error:
xis-1.errnois set toERANGE(but see BUGS again, I'm so serious). A divide-by-zero floating-point exception (FE_DIVBYZERO) is raised.
β οΈ when the manpage says "but see BUGS" twice, you go read BUGS. that's the vibe check. β οΈ
π ATTRIBUTES π (for an explanation of the terms used in this section, see attributes(7))
- Interface:
log1p(),log1pf(),log1pl()β Attribute: Thread safety β Value: MT-Safe
translation: all three of them are MT-Safe, so she's not gonna start drama across your threads. periodt. π
π STANDARDS π
C11, POSIX.1-2008. certified, validated, official. π
π°οΈ HISTORY π°οΈ
C99, POSIX.1-2001. she's been around since the turn of the millennium and she's still that girl. β
π BUGS π
- Before glibc
2.22, the glibc implementation did not seterrnotoEDOMwhen a domain error occurred. - Before glibc
2.22, the glibc implementation did not seterrnotoERANGEwhen a range error occurred.
π¨ so if you're on old glibc and you're checking errno, bestie, she ghosted it. don't be surprised. π¨
π SEE ALSO π
exp(3), expm1(3), log(3) β go read her friends too, they're all part of the same clique. π
and that's the whole page, bestie β this was the log1p(3) entry from Linux man-pages 6.20, dated 2026-02-08, and you absolutely ate by reading the whole thing. go compute something tiny and near zero responsibly. mwah. π
β¨π
π¦ 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