logGamma
logGamma(
x):number
Defined in: packages/math-analysis/src/log-gamma.ts:32
The natural logarithm of the gamma function, ln Γ(x).
Use it whenever Γ itself would not fit. Γ(a) overflows binary64 past a ≈ 171.6, while ln Γ(a) stays finite for every argument a caller can
represent — which is what makes the ratios of gamma functions behind
beta and the probability distributions computable at all.
Defined for x > 0 only. That is not a gap: Γ alternates sign between
consecutive negative integers and has a pole at each of them, so no real
logarithm covers the negative reals. Use gamma there, which carries
the sign.
O(1) time, O(1) memory — a fixed nine-term series.
Parameters
Section titled “Parameters”number
A positive real.
Returns
Section titled “Returns”number
ln Γ(x), or NaN when x ≤ 0 or x is NaN.
Example
Section titled “Example” logGamma(172); // 711.71472580229 — finite where gamma(172) is Infinity logGamma(1e6); // 12815504.56914761 logGamma(-1); // NaN — no real logarithm on the negative reals ```;
## See
- [gamma](gamma.md) for the value itself, and for negative arguments. - [The gamma and beta functions](https://anthochamp.pages.grenadine.io/node-essentials/topics/math/functions/gamma/)