LGAMMA(3P)
โจ LGAMMA(3P) โจ
okay bestie, welcome to the POSIX Programmer's Manual ๐ โ this one's about the log gamma function, and she is literally the moment.
๐ธ PROLOG ๐ธ
Real talk before we start: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so pls consult the corresponding Linux manual page for the details of Linux behavior), or honestly the interface may not be implemented on Linux at all. ๐ So likeโฆ vibe check your platform first, iykyk.
๐ NAME ๐
lgamma, lgammaf, lgammal, signgam โ the log gamma function, girlies. ๐
๐ฆ SYNOPSIS ๐ฆ
#include <math.h>
double lgamma(double x);
float lgammaf(float x);
long double lgammal(long double x);
extern int signgam;
๐ DESCRIPTION ๐
The functionality described on this reference page is aligned with the ISO C standard. And like, any conflict between the requirements described here and the ISO C standard is unintentional โ this volume of POSIX.1โ2017 defers to the ISO C standard, periodt.
These functions shall compute log_e โฮ(x)โ where ฮ(x) is defined as โซe^โt t^xโ1dt. And the argument x need not be a non-positive integer (ฮ(x) is defined over the reals, except the non-positive integers). She's flexible like that. ๐โ๏ธ
If x is NaN, -Inf, or a negative integer, the value of signgam is unspecified. Not undefined-undefined, justโฆ unspecified. Do not build your whole personality on it.
โ ๏ธ bestie, heads up: These functions need not be thread-safe. No cap.
An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if errno is non-zero, or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred. That's the whole vibe check. โ
๐ RETURN VALUE ๐
Upon successful completion, these functions shall return the logarithmic gamma of x. Slay. โจ
- If
xis a non-positive integer, a pole error shall occur andlgamma(),lgammaf(), andlgammal()shall return+HUGE_VAL,+HUGE_VALF, and+HUGE_VALL, respectively. ๐ณ๏ธ - If the correct value would cause overflow, a range error shall occur and
lgamma(),lgammaf(), andlgammal()shall returnยฑHUGE_VAL,ยฑHUGE_VALF, andยฑHUGE_VALL(having the same sign as the correct value), respectively. ๐ญ - If
xisNaN, aNaNshall be returned. ๐ซ - If
xis1or2,+0shall be returned. ๐ฏ - If
xisยฑInf,+Infshall be returned. โพ๏ธ
๐ ERRORS ๐
These functions shall fail if:
- Pole Error โ the
xargument is a negative integer or zero.- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - If the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the divide-by-zero floating-point exception shall be raised.
- If the integer expression
- Range Error โ the result overflows.
- If the integer expression
(math_errhandling & MATH_ERRNO)is non-zero, thenerrnoshall be set to[ERANGE]. - If the integer expression
(math_errhandling & MATH_ERREXCEPT)is non-zero, then the overflow floating-point exception shall be raised.
- If the integer expression
The following sections are informative. (aka, not the rules, just the gossip ๐ซ)
๐ EXAMPLES ๐
None. ๐ Not one example. We're on our own, bestie.
๐ง APPLICATION USAGE ๐ง
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other, but at least one of them must be non-zero. Like two besties who don't text each other but both still gotta show up. ๐ซถ
๐ RATIONALE ๐
None. The reasoning? Mysterious. Main character energy. ๐
โญ FUTURE DIRECTIONS โญ
None. The future is unclear but the vibes are immaculate. ๐ฎ
๐ SEE ALSO ๐
exp()feclearexcept()fetestexcept()isnan()
Also, from the Base Definitions volume of POSIX.1โ2017: Section 4.20, Treatment of Error Conditions for Mathematical Functions, and <math.h>. ๐
๐ COPYRIGHT ๐
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, babe ๐ซถ โ brought to you by IEEE/The Open Group, dated 2017, filed under LGAMMA(3P). go forth and compute log gamma responsibly. mwah ๐
๐ฆ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 ยท custom
- alpine 3.23: man-pages-posix 2017a-r0 ยท custom
- alpine 3.24: man-pages-posix 2017a-r0 ยท custom
- arch rolling: man-pages 6.19-1
- 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-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 ยท SUSE-IEEE
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms