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 x is a NaN, a NaN is returned. she matches your energy.
  • If x is positive infinity, positive infinity is returned. iconic behavior, honestly.
  • If x is -1, a pole error occurs, and the functions return -HUGE_VAL, -HUGE_VALF, or -HUGE_VALL, respectively. πŸ’€
  • If x is 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: x is less than -1. errno is set to EDOM (but see BUGS, bestie, it's messy down there). An invalid floating-point exception (FE_INVALID) is raised.
  • Pole error: x is -1. errno is set to ERANGE (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 set errno to EDOM when a domain error occurred.
  • Before glibc 2.22, the glibc implementation did not set errno to ERANGE when 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms