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 x is a non-positive integer, a pole error shall occur and lgamma(), lgammaf(), and lgammal() 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(), and lgammal() shall return ยฑHUGE_VAL, ยฑHUGE_VALF, and ยฑHUGE_VALL (having the same sign as the correct value), respectively. ๐Ÿ˜ญ
  • If x is NaN, a NaN shall be returned. ๐Ÿซ 
  • If x is 1 or 2, +0 shall be returned. ๐ŸŽฏ
  • If x is ยฑInf, +Inf shall be returned. โ™พ๏ธ

๐Ÿ’€ ERRORS ๐Ÿ’€

These functions shall fail if:

  • Pole Error โ€” the x argument is a negative integer or zero.
    • If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall 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.
  • Range Error โ€” the result overflows.
    • If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [ERANGE].
    • If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow floating-point exception shall be raised.

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>. ๐Ÿ“š


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