Close: 2,403 of 4,541 recorded answers differ in the last bits, worst 7 ULP
Everything else matches (4,538 in the answer bank and 3 workbook cells). Last-bit means a finite number within 16 ULP of Excel's. How we measure this · See the Rust code
Local names in 40 languages
Language
Name in Excel
Arabic
GAMMALN
Bulgarian
GAMMALN
Czech
GAMMALN
Danish
GAMMALN
German
GAMMALN
Greek
GAMMALN
English (Australia)
GAMMALN
English (United Kingdom)
GAMMALN
English (United States)
GAMMALN
Spanish
GAMMA.LN
Estonian
GAMMALN
Finnish
GAMMALN
French
LNGAMMA
Hebrew
GAMMALN
Croatian
GAMMALN
Hungarian
GAMMALN
Indonesian
GAMMALN
Italian
GAMMALN
Japanese
GAMMALN
Korean
GAMMALN
Lithuanian
GAMMALN
Latvian
GAMMALN
Norwegian
GAMMALN
Dutch
GAMMA.LN
Polish
ROZKŁAD.LIN.GAMMA
Portuguese (Brazil)
GAMMALN
Portuguese (Portugal)
LNGAMA
Romanian
GAMMALN
Russian
ГАММАНЛОГ
Slovak
GAMMALN
Slovenian
GAMMALN
Serbian (Latin)
GAMMALN
Swedish
GAMMALN
Thai
GAMMALN
Turkish
GAMALN işlevi
Ukrainian
GAMMALN
Vietnamese
GAMMALN
Chinese (Simplified)
GAMMALN
Chinese (Hong Kong)
GAMMALN
Chinese (Traditional)
GAMMALN
Names from Microsoft's support site.
What it does
GAMMALN(x)
GAMMALN(x) returns the natural logarithm of the gamma function:
GAMMALN(x) = ln Γ(x) = ln ∫₀^∞ t^{x−1} e^{−t} dt for x > 0
Domain: the positive reals. Excel does not expose the negative-argument branch (where Γ
alternates sign and its logarithm is complex), so the documented domain is x > 0 with #NUM!
outside it. Note this makes GAMMALN a restriction of LN(GAMMA(x)), not an equivalent: the
latter is defined on more of the line and overflows on far less of it.
Range and shape. ln Γ is strictly convex on (0, ∞) — this is the Bohr–Mollerup
characterisation, and it is the property that makes ln Γ the natural object rather than Γ. It
falls from +∞ at x → 0⁺ to a single minimum near x ≈ 1.4616 (value ≈ −0.1214) and rises
thereafter without bound. It has exactly two zeros, at x = 1 and x = 2, because Γ(1) =
Γ(2) = 1. Those two zeros are the source of the function's only real accuracy trap; see
Numerical notes.
The identities.
ln Γ(x + 1) = ln x + ln Γ(x) (recurrence)
ln Γ(n) = ln (n − 1)! for positive integers n
ln Γ(x) ~ (x − ½) ln x − x + ½ ln(2π) + 1/(12x) − 1/(360x³) + … (Stirling, A&S 6.1.40)
Microsoft states the integer relation from the other side: "The number e raised to the
GAMMALN(i) power, where i is an integer, returns the same result as (i − 1)!" That is exact as
mathematics and, as with GAMMA, is a floating-point claim about the round trip rather than a
guarantee — exp(lnΓ(i)) need not land on the integer.
Why this function exists at all. Γ overflows binary64 a little above x ≈ 171.6; ln Γ stays
comfortably finite until x is astronomically large. Every ratio of gamma functions — binomial
coefficients, beta functions, distribution normalising constants, multinomials — should be
computed as a difference of log-gammas and exponentiated once at the end, if at all. That is
the entire practical argument for the function, and it is why GAMMALN appears far more often
than GAMMA in careful spreadsheet work.
Arguments
Argument
Meaning
Default
x
The value at which to evaluate ln Γ. Required.
—
Try it
Quirks
Result and edge cases
Returns Number.
Small positive x behaves like −ln x: ln Γ(x) = −ln x − γx + O(x²). At the bottom of the
double range the value is large and finite, which is the good news GAMMALN exists to
deliver — where GAMMA overflows, GAMMALN still answers.
x ≤ 0 is documented #NUM!, including the poles and the whole negative axis where the
real logarithm of Γ does not exist.
Array arguments lift elementwise through the module's broadcast helper.
Errors
As documented by Microsoft:
Error
Condition
#VALUE!
x is nonnumeric
#NUM!
x ≤ 0
GAMMALN from 3 to 8 is a stored recurrence, and GAMMALN(3) is one unit above ln 2
With RN(v) meaning v rounded to 64 bits on the x87 unit and then stored to binary64, write x = n + y with n the integer part. For 3 < x < 8, Excel forms z = (y+2)(y+3)...(y+n-1) from the left with every product RN, and GAMMALN(x) is RN(RN(ln z) + GAMMALN(2+y)). So answers on this range carry the rounding of a value on [2,3]. x = 3 itself belongs to the band on [2,3], not to this route, and returns 0x3fe62e42fefa39f0, one unit above the stored ln 2, although GAMMALN(3) is exactly ln 2.
Explanation (inferred): That GAMMALN.PRECISE takes the same route is inferred: the 30,000 answers are GAMMALN, and the two functions agree at every shared recorded input tried, including 3.
Formula
Excel
Mathematical value
GAMMALN(3) Excel 16.0 build 20131, platform and bitness not recorded, AMD Ryzen 7 4800HInputs and reference value
Number supplied through a cell.
x: 3 0x4008000000000000
ln 2, correctly rounded.
0.6931471805599454 0x3fe62e42fefa39f0
0.6931471805599453 0x3fe62e42fefa39ef
GAMMALN.PRECISE(3) Excel 16.0 build 20131, platform and bitness not recorded, AMD Ryzen 7 4800HInputs and reference value
Number supplied through a cell.
x: 3 0x4008000000000000
ln 2, correctly rounded.
0.6931471805599454 0x3fe62e42fefa39f0
0.6931471805599453 0x3fe62e42fefa39ef
GAMMALN(2.020222407046596) Excel 16.0 build 20527, Windows; bitness and CPU not recorded in this readingInputs and reference value
Number supplied through a cell.
x: 2.020222407046596 0x4000296a5d874ad0
0.008681034861562235 0x3f81c75cc69b54fc
—
GAMMALN(6.020222407046596) Excel 16.0 build 20527, Windows; bitness and CPU not recorded in this readingInputs and reference value
Number supplied through a cell.
x: 6.020222407046596 0x401814b52ec3a568
mpmath loggamma at 800 bits from the binary64 input, correctly rounded.
The classical design is a three-region split. Every serious implementation of ln Γ does the
same three things, and their boundaries are the implementation's fingerprint:
Small x — use the recurrence to lift x into the well-behaved region:
ln Γ(x) = ln Γ(x + 1) − ln x. This is essential because the Lanczos and rational forms both
degrade as x → 0, and the reciprocal singularity is best handled by an explicit ln x term.
The middle, roughly [1, 8] — a minimax rational or Chebyshev approximation. Cody &
Hillstrom's 1967 Chebyshev approximations are the classical answer and the ancestor of
SPECFUN's ALGAMA/DLGAMA, of fdlibm's lgamma, and of most libm implementations. Excel
differs here: from 3 to 8 it uses a stored recurrence (FN-GAMMALN-001).
Large x — Stirling's asymptotic series (A&S 6.1.40), typically with terms through 1/x⁷ or
so, above a seam around x = 8 to 12.
The two zeros are the trap. Because ln Γ vanishes at x = 1 and x = 2, the relative error
near those points is unbounded for any implementation that computes the value directly: the
answer is a small number obtained by cancelling large terms, and the surviving digits are few.
fdlibm handles this by evaluating a polynomial in (x − 1) or (x − 2) directly near each zero,
so that the small quantity is the argument rather than a difference. An implementation that
skips that step will produce residuals that spike sharply in two narrow bands and look fine
everywhere else — which is exactly the pattern that makes a coarse accuracy sweep miss the
problem.
Argument reduction is the other half. The recurrence multiplies by x, so lifting a small
argument requires computing ln x accurately and subtracting; near x = 1 that subtraction is
itself a cancellation. The interaction of the reduction seam with the zero at x = 1 is the
subtlest part of the whole function.
What upstream identified. The evidence records describe an identification campaign that
pinned a structural form for Excel's surface — a threshold near 0.7, a seam at 8.0, and a
Stirling form beyond it — and then fitted coefficients, with two held-out tests plus one fresh
never-probed corpus used to decide which candidate landed. Two properties of that campaign
matter to a reader and are stated in the records themselves. First, the held-out tests were held
out from the coefficient fits, not from the structural identification: the threshold, the
seam and the form were pinned on batteries surrounding those very rows. Second, the arguments in
both held-out tests are GAMMALN.PRECISE captures, so the inheritance runs from .PRECISE to
GAMMALN and not the other way — the surface with the fresh corpus of its own is this one, and
the record says so explicitly.
Recommended practice. Prefer GAMMALN over LN(GAMMA(x)) unconditionally: it is defined on
a larger useful range, it does not overflow where GAMMA does, and it avoids the
exp-then-log round trip. Where a ratio of gammas is wanted, keep it in log space to the last
step. Where an exact small factorial is wanted, use the integer route, not this one.
Rust code
Show the CalcFunc source of this function
Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.
No implementation has been published with a Handbook test suite for this function.
Version differences
The recorded environments below distinguish a reading from a same-input comparison. Counts describe captured inputs in each environment; overlapping captures and comparisons are not totals of unique worksheet calls.
Excel 16.0 build
Platform and CPU
Captured inputs
19929
Windows, bitness not recorded, CPU not recorded
43
20131
Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics
4,450
20228
Windows, 64-bit, CPU not recorded
88
XC-GAMMALN-001: build 19929 versus build 20228; 1 same-input pairs, 0 differing answers. Compared axes: excel-build. Numeric answers were compared by their recorded binary64 bits; other answers by typed value.
XC-GAMMALN-002: build 20131 versus build 20228; 13 same-input pairs, 0 differing answers. Compared axes: excel-build. Numeric answers were compared by their recorded binary64 bits; other answers by typed value.
Agreement on these compared inputs does not establish agreement on unmeasured inputs.
GAMMALN(3) returned 0.6931471805599454 (0x3fe62e42fefa39f0). Inputs were supplied through cells using Value2. These are controls from this environment, not a same-input comparison with another build.
Windows; bitness and CPU not recorded in this reading
GAMMALN(2.020222407046596) returned 0.008681034861562235 (0x3f81c75cc69b54fc). GAMMALN(6.020222407046596) returned 4.8220305792560145 (0x401349c26258ddb7). Inputs were supplied through cells using Value2. These are controls from this environment, not a same-input comparison with another build.
43 captured inputs are indexed for this environment. Capture dates are not recorded. This is a reading count, not a comparison with another build.
Excel 16.0 build 20131
Windows, bitness not recorded, AMD Ryzen 7 4800H with Radeon Graphics
4,450 captured inputs are indexed for this environment. Capture dates: 2026-07-11 to 2026-07-18. This is a reading count, not a comparison with another build.
Excel 16.0 build 20228
Windows, 64-bit, CPU not recorded
88 captured inputs are indexed for this environment. Capture dates: 2026-08-09 to 2026-08-09. This is a reading count, not a comparison with another build.
Alternatives
Relationships
GAMMA — the value rather than its logarithm. The two share a module and
not a numeric path: upstream's landed log-gamma kernel is wired only to the two GAMMALN
surfaces, and the source says so in as many words. LN(GAMMA(x)) and GAMMALN(x) are
therefore different computations with different accuracy and different domains, and the
first overflows where the second does not.
FACT, COMBIN, MULTINOMIAL — combinatorial quantities better computed through this
function than through GAMMA or FACT when the intermediate factorials would overflow.
COMBIN(n,k) as EXP(GAMMALN(n+1) − GAMMALN(k+1) − GAMMALN(n−k+1)) is the standard rewrite,
and it is less accurate for small n than an exact integer route — a real trade, not a free
improvement.
GAMMA.DIST, BETA.DIST, POISSON.DIST — consumers: their
normalising constants are log-gammas.