Skip to content

LogGamma ​

The log-gamma function ln⁡Γ(z)\ln\Gamma(z) as an analytic continuation (branch cut on (−∞,0](-\infty, 0]), which differs from ln⁡(Γ(z))\ln(\Gamma(z)) by multiples of 2πi2\pi i off the positive axis.

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaGamma functionMathWorldLogGammaFunctionGammaFunctionWikidataQ190573Encyclopedia of MathematicsGamma-functionnLabGamma functionBritannicascience/gamma-functionDLMF5.2.E1FungrimLogGammaWolfram LanguageLogGamma✓
LogGamma(z)the log-gamma function ln⁡Γ(z)\ln\Gamma(z), analytically continued.
SageMathlog_gamma(z)SymPyloggamma(z)mpmathloggamma(z)Juliaenumeratio_ball(lgamma, z)Rustln_gamma(z)
Typed signatures
TypePackageApplies
(complex | infinity) -> numberanalyticreplaces compute-enginealways
(complex | infinity) -> numbercompute-enginealways

Domain: Special functions

Details
  • For real z>0z > 0 it is simply ln⁡Γ(z)\ln\Gamma(z): ln⁡Γ(n)=ln⁡(n−1)!\ln\Gamma(n) = \ln (n-1)!, ln⁡Γ(12)=12ln⁡π\ln\Gamma(\tfrac12) = \tfrac12\ln\pi -- where it agrees with compute-engine's own GammaLn.
  • Elsewhere it is the continuation across the upper and lower half-planes, continuous off (−∞,0](-\infty, 0] — the convention Wolfram's LogGamma\mathrm{LogGamma} and mpmath's loggamma share. ln⁡(Γ(z))\ln(\Gamma(z)) with a principal logarithm jumps by 2πi2\pi i wherever Γ\Gamma crosses the negative axis; this does not. GammaLn is that principal version, so the two genuinely differ: at z=−5/2z = -5/2, GammaLn is −0.0562-0.0562 while LogGamma is −0.0562−3πi-0.0562 - 3\pi i.
  • +∞+\infty at the poles of Γ\Gamma, the nonpositive integers.
  • Numerically, Stirling's series for large Re⁡(z)\operatorname{Re}(z) with the recurrence ln⁡Γ(z)=ln⁡Γ(z+n)−∑k<nln⁡(z+k)\ln\Gamma(z) = \ln\Gamma(z+n) - \sum_{k<n}\ln(z+k) — in principal logarithms, which for Im⁡(z)≠0\operatorname{Im}(z) \ne 0 is exactly the continuation. compute-engine has a complex Gamma but no LogGamma of its own.

Plot

ComplexPlot
real slice

Examples

4 more kept as data, checked against the oracles
Basic #

ln⁡Γ(3)=ln⁡2!=ln⁡2\ln\Gamma(3) = \ln 2! = \ln 2

live ↗
InLogGamma(3)\mathrm{LogGamma}(3)Outln⁡(2)\ln(2)

ln⁡Γ(1)=0\ln\Gamma(1) = 0

live ↗
InLogGamma(1)\mathrm{LogGamma}(1)Out00

ln⁡Γ(2.5)=ln⁡1.3293…\ln\Gamma(2.5) = \ln 1.3293\ldots — to the engine's working precision, not a double: right of the imaginary axis this goes through compute-engine's own GammaLn

live ↗
InLogGamma(2.5)\mathrm{LogGamma}(2.5)Out0.284 682 870 472 919 159 6320.284\,682\,870\,472\,919\,159\,632

ln⁡Γ(5)=ln⁡4!=ln⁡24\ln\Gamma(5) = \ln 4! = \ln 24, split into prime logarithms

live ↗
InLogGamma(5)\mathrm{LogGamma}(5)Out3ln⁡(2)+ln⁡(3)3\ln(2)+\ln(3)
Scope #

To the engine's working precision

live ↗
InLogGamma(2.2)\mathrm{LogGamma}(2.2)Out0.096 947 466 790 638 776 4920.096\,947\,466\,790\,638\,776\,492

Complex arguments

live ↗
InLogGamma(2.5+3i)\mathrm{LogGamma}(2.5+3i)Out−1.470 954 610 348 842 5+2.822 615 638 260 8i-1.470\,954\,610\,348\,842\,5+2.822\,615\,638\,260\,8i

Threads elementwise over an array

live ↗
InLogGamma([[12,−1],[0,12]])\mathrm{LogGamma}(\bigl\lbrack\bigl\lbrack\frac{1}{2}, -1\bigr\rbrack, \bigl\lbrack0, \frac{1}{2}\bigr\rbrack\bigr\rbrack)Out[[ln⁡(π)2,∞],[∞,ln⁡(π)2]]\bigl\lbrack\bigl\lbrack\frac{\ln(π)}{2}, ∞\bigr\rbrack, \bigl\lbrack∞, \frac{\ln(π)}{2}\bigr\rbrack\bigr\rbrack

Exact negative half-integers: ln⁡Γ(−32)=ln⁡4π3−2πi\ln\Gamma(-\tfrac32) = \ln\tfrac{4\sqrt\pi}{3} - 2\pi i

live ↗
InLogGamma(−32)\mathrm{LogGamma}(-\frac{3}{2})Outln⁡(4π3)−2iπ\ln(\frac{4\sqrt{π}}{3})-2i π

ln⁡Γ(∞)=∞\ln\Gamma(\infty) = \infty

live ↗
InLogGamma(∞)\mathrm{LogGamma}(∞)Out∞∞

Huge arguments: ln⁡Γ(10300)≈6.898×10302\ln\Gamma(10^{300}) \approx 6.898\times10^{302}, from Stirling's series directly rather than through Γ(10300)\Gamma(10^{300}) itself, which overflows a double long before its log would; the answer carries the engine's precision

live ↗
InN(LogGamma(10300))N(\mathrm{LogGamma}(10^{300}))Out6.897 755 278 982 137 052 05⋅103026.897\,755\,278\,982\,137\,052\,05\cdot10^{302}

Interval arithmetic: decreasing here, so the endpoints swap

live ↗
InLogGamma(Interval(0.41,0.42))\mathrm{LogGamma}(\mathrm{Interval}(0.41, 0.42))OutInterval(0.746 863 727 128 013 3,0.771 422 463 394 747 7)\mathrm{Interval}(0.746\,863\,727\,128\,013\,3, 0.771\,422\,463\,394\,747\,7)

Uncertainty propagation, with ψ(1.2)\psi(1.2) as the slope

live ↗
InLogGamma(Around(1.2,0.01))\mathrm{LogGamma}(\mathrm{Around}(1.2, 0.01))OutAround(−0.085 374 090 003 315 85,0.002 890 398 965 921 883)\mathrm{Around}(-0.085\,374\,090\,003\,315\,85, 0.002\,890\,398\,965\,921\,883)

To 30 significant digits, the last one correctly rounded

live ↗
InN(LogGamma(13),30)N(\mathrm{LogGamma}(\frac{1}{3}), 30)Out0.985 420 646 927 767 069 187 174 036 9780.985\,420\,646\,927\,767\,069\,187\,174\,036\,978

ln⁡∣Γ(−5/2)∣\ln|\Gamma(-5/2)| is correctly rounded, not carried through a double ln⁡sin⁡πz\ln\sin\pi z reflection

live ↗
InN(LogGamma(−2.5))N(\mathrm{LogGamma}(-2.5))Out−0.056 243 716 497 674 054−9.424 777 960 769 38i-0.056\,243\,716\,497\,674\,054-9.424\,777\,960\,769\,38i

LogGamma is the continuation: the same real part as GammaLn at −0.5-0.5, with imaginary part −π-\pi (Wolfram's LogGamma[-0.5] and mpmath's loggamma(-0.5))

live ↗
InLogGamma(−0.5)\mathrm{LogGamma}(-0.5)Out1.265 512 123 484 645 4−3.141 592 653 589 793i1.265\,512\,123\,484\,645\,4-3.141\,592\,653\,589\,793i
Properties #

ln⁡Γ(12)=12ln⁡π\ln\Gamma(\tfrac12) = \tfrac12 \ln\pi, from Γ(12)=π\Gamma(\tfrac12) = \sqrt\pi

live ↗
InLogGamma(12)\mathrm{LogGamma}(\frac{1}{2})Outln⁡(π)2\frac{\ln(π)}{2}

A pole of Γ\Gamma

live ↗
InLogGamma(0)\mathrm{LogGamma}(0)Out∞∞

On the negative axis: Γ(−32)=43π>0\Gamma(-\tfrac32) = \tfrac43\sqrt\pi > 0, but the continuation carries −2πi-2\pi i

live ↗
InLogGamma(−1.5)\mathrm{LogGamma}(-1.5)Out0.860 047 015 376 481−6.283 185 307 179 586i0.860\,047\,015\,376\,481-6.283\,185\,307\,179\,586i

Half-integers past 12\tfrac12: ln⁡Γ(32)=ln⁡π2\ln\Gamma(\tfrac32) = \ln\tfrac{\sqrt\pi}{2}

live ↗
InLogGamma(32)\mathrm{LogGamma}(\frac{3}{2})Outln⁡(π2)\ln(\frac{\sqrt{π}}{2})
Possible issues #

Off the positive axis this is the continuation: ln⁡(Γ(−2.5+1.5i))\ln(\Gamma(-2.5+1.5i)) with a principal log has imaginary part −1.4299-1.4299, a full 2π2\pi away

live ↗
InLogGamma(−2.5+1.5i)\mathrm{LogGamma}(-2.5+1.5i)Out−3.717 513 451 191 792 7−7.713 065 525 834 192i-3.717\,513\,451\,191\,792\,7-7.713\,065\,525\,834\,192i

LogGamma(NegativeInfinity) is Indeterminate: the negative axis is LogGamma's own branch cut, where Gamma oscillates in sign between poles with no single limit

live ↗
InLogGamma(−∞)\mathrm{LogGamma}(-∞)OutIndeterminate⁡\operatorname{Indeterminate}

Known value · DLMF 5.2, via Gamma(NegativeInfinity) = Indeterminate

About
Examples25
Checked againstWolfram Language 24 agreeSageMath 19 agree2 differ2 errorSymPy 20 agree2 differ2 errormpmath 19 agree4 errorJulia 17 agree6 errorRust 9 agree1 differ3 unevaluated6 error
CrosswalkWikipediaMathWorld ×2WikidataEncyclopedia of MathematicsnLabBritannicaDLMFFungrimWolfram LanguageSageMathSymPympmathJuliaRust

Implementation

referenceenginenotatio

The continuation pinned by lnΓ(1) = 0 and (lnΓ)′ = ψ — which is what makes it the continuation and not Ln(Gamma(z)), whose branch differs off the positive axis.

nativeenginetypescriptpackages/ce-patches/src/compute-engine/numerics/log-gamma.ts
mappedexternalwolfram / mpmathpackages/oracle/src/mappings.ts

LogGamma[z] and mpmath.loggamma(z) — both the continuation, not Log[Gamma[z]].

mappedsympypackages/oracle/src/mappings.ts
mappedmpmathpackages/oracle/src/mappings.ts

The principal branch, cut along the negative reals, as in Wolfram.

mappedsagepackages/oracle/src/mappings.ts
mappedjuliapackages/oracle/src/mappings.ts
mappedrustpackages/oracle/src/mappings.ts

See also: Gamma, GammaLn, LogBarnesG, Digamma