GAMMALN
Quirk foundCategory: Statistical · Last tested 2026-09-01
Real compatibility results for the GAMMALN function: executed in Excel for the web, Google Sheets and LibreOffice Calc, with desktop Excel behavior from Microsoft’s official documentation (we do not run desktop Excel — Excel for the web is a different application and is executed separately). Syntax and links to that documentation are below.
Support matrix
| Engine | Documented | Live-tested | Verdict |
|---|---|---|---|
| Excel (desktop) | Yes | No — documented only | n/a |
| Excel for the web | — | Yes (recalc, 2026-09-01) | Supported, behaves as documented |
| Google Sheets | Yes | Yes (Drive import, 2026-08-31) | Supported, behaves as documented |
| LibreOffice Calc | Yes | Yes (25.8.7.3, 2026-08-31) | Quirk found |
LibreOffice version history
We executed the same test cases under each LibreOffice release to show exactly when GAMMALN’s support changed — not documentation claims, real results.
| LibreOffice version | Verdict | Tested |
|---|---|---|
| 24.2.0.3 | Quirk found | 2026-08-31 |
| 24.8.7.2 | Quirk found | 2026-08-31 |
| 25.2.0.3 | Quirk found | 2026-08-31 |
| 25.8.7.3 | Quirk found | 2026-08-31 |
Why isn't GAMMALN working in LibreOffice?
GAMMALN exists in LibreOffice 25.8.7.3, but it is not a drop-in match for
Excel — our executed tests found real behavioral differences (detailed in the test results on this
page). If a formula that works in Excel or Google Sheets misbehaves in LibreOffice, compare your usage
against the failing cases above before assuming your data is wrong.
Discovered quirks
-
=GAMMALN(0) on
LibreOffice Calc returned
#VALUE!, but the documented/expected
result is #NUM!.
Provenance
Excel documents: "If x <= 0, GAMMALN returns the #NUM! error value." Gamma has a pole at 0, so its logarithm diverges. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one.; MISMATCH vs expected: expected '#NUM!', got '#VALUE!'
-
=GAMMALN(-1) on
LibreOffice Calc returned
#VALUE!, but the documented/expected
result is #NUM!.
Provenance
Excel documents: "If x <= 0, GAMMALN returns the #NUM! error value." Note this is a STRICTER domain than GAMMA's: GAMMA(-3.75) is a documented finite value, but GAMMALN(-3.75) is excluded outright, because the gamma function alternates sign on the negative axis and its real logarithm would be undefined half the time. Asserted separately from the zero case for that reason. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one.; MISMATCH vs expected: expected '#NUM!', got '#VALUE!'
Executed test cases
Excel for the web (executed 2026-09-01 via OneDrive recalculation)
These values come from Excel for the web, not from desktop Excel. They are two different implementations of the calculation engine, and this run measured only the web one: the corpus was uploaded to OneDrive as .xlsx, recalculated by Excel for the web on open, and downloaded again for readback. Excel for the web is a rolling service with no pinnable version, so the run is identified by its date. Where a value here disagrees with the Expected column — which is Microsoft’s documentation of the desktop product — we cannot tell you whether the web engine diverges from the desktop one or the documentation is wrong about both, because we do not run desktop Excel.
| Formula | Description | Result | Expected | Verdict |
|---|---|---|---|---|
| =ROUND(GAMMALN(4),12) | Microsoft's documented worked example: the natural logarithm of the gamma function at 4 | 1.791759469228 | 1.791759469228ProvenanceMicrosoft publishes '=GAMMALN(4)' with the result 1.7917595. Derived independently two ways that agree to every digit mpmath prints at 50 places: mpmath's loggamma(4) = 1.7917594692280550008, and -- using the page's own stated identity that "The number e raised to the GAMMALN(i) power, where i is an integer, returns the same result as (i - 1)!" -- ln(3!) = ln(6) = 1.7917594692280550008. Rounds to exactly the published 1.7917595 at the 7 dp the page prints; asserted at 12 dp because that is still comfortably inside double precision. |
Matched |
| =ROUND(EXP(GAMMALN(6)),9) | The page's own identity: e raised to GAMMALN(i) is (i-1)! | 120 | 120ProvenanceMicrosoft states: "The number e raised to the GAMMALN(i) power, where i is an integer, returns the same result as (i - 1)!". At i = 6 that is 5! = 120, an exact integer. Asserted as EXP(...) inside the engine so it exercises the log-gamma implementation against a value that is known exactly, rather than comparing two printed decimals. ROUND at 9 dp absorbs the round-trip through the exponential, which cannot be exact in binary floating point; 120 is recovered to far more than 9 decimals in the reference computation (mpmath: 119.99999999999999999997). |
Matched |
| =ROUND(GAMMALN(0.5)-LN(SQRT(PI())),12) | The classical value ln(Gamma(1/2)) = ln(sqrt(pi)), asserted as a difference of zero | 0 | 0ProvenanceNot a published example; the standard closed form, checked against the engine's own LN, SQRT and PI so that it tests the log-gamma implementation rather than a printed constant. mpmath at 50 digits: loggamma(0.5) = 0.57236494292470008707, and ln(sqrt(pi)) = 0.57236494292470008707. |
Matched |
| =GAMMALN(0) | Zero, which the page excludes | #NUM! | #NUM!ProvenanceExcel documents: "If x <= 0, GAMMALN returns the #NUM! error value." Gamma has a pole at 0, so its logarithm diverges. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Matched |
| =GAMMALN(-1) | A negative argument, also excluded | #NUM! | #NUM!ProvenanceExcel documents: "If x <= 0, GAMMALN returns the #NUM! error value." Note this is a STRICTER domain than GAMMA's: GAMMA(-3.75) is a documented finite value, but GAMMALN(-3.75) is excluded outright, because the gamma function alternates sign on the negative axis and its real logarithm would be undefined half the time. Asserted separately from the zero case for that reason. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Matched |
| =GAMMALN("abc") | A non-numeric argument | #VALUE! | #VALUE!ProvenanceExcel documents: "If x is nonnumeric, GAMMALN returns the #VALUE! error value." |
Matched |
Google Sheets (executed 2026-08-31 via Drive import)
Google Sheets is a rolling service with no pinnable version, so this run is identified by its date. The corpus was imported to Drive as .xlsx, recalculated by Sheets, and exported back for readback.
| Formula | Description | Result | Expected | Verdict |
|---|---|---|---|---|
| =ROUND(GAMMALN(4),12) | Microsoft's documented worked example: the natural logarithm of the gamma function at 4 | 1.791759469 | 1.791759469228ProvenanceMicrosoft publishes '=GAMMALN(4)' with the result 1.7917595. Derived independently two ways that agree to every digit mpmath prints at 50 places: mpmath's loggamma(4) = 1.7917594692280550008, and -- using the page's own stated identity that "The number e raised to the GAMMALN(i) power, where i is an integer, returns the same result as (i - 1)!" -- ln(3!) = ln(6) = 1.7917594692280550008. Rounds to exactly the published 1.7917595 at the 7 dp the page prints; asserted at 12 dp because that is still comfortably inside double precision. |
Matched |
| =ROUND(EXP(GAMMALN(6)),9) | The page's own identity: e raised to GAMMALN(i) is (i-1)! | 120 | 120ProvenanceMicrosoft states: "The number e raised to the GAMMALN(i) power, where i is an integer, returns the same result as (i - 1)!". At i = 6 that is 5! = 120, an exact integer. Asserted as EXP(...) inside the engine so it exercises the log-gamma implementation against a value that is known exactly, rather than comparing two printed decimals. ROUND at 9 dp absorbs the round-trip through the exponential, which cannot be exact in binary floating point; 120 is recovered to far more than 9 decimals in the reference computation (mpmath: 119.99999999999999999997). |
Matched |
| =ROUND(GAMMALN(0.5)-LN(SQRT(PI())),12) | The classical value ln(Gamma(1/2)) = ln(sqrt(pi)), asserted as a difference of zero | 0 | 0ProvenanceNot a published example; the standard closed form, checked against the engine's own LN, SQRT and PI so that it tests the log-gamma implementation rather than a printed constant. mpmath at 50 digits: loggamma(0.5) = 0.57236494292470008707, and ln(sqrt(pi)) = 0.57236494292470008707. |
Matched |
| =GAMMALN(0) | Zero, which the page excludes | #NUM! | #NUM!ProvenanceExcel documents: "If x <= 0, GAMMALN returns the #NUM! error value." Gamma has a pole at 0, so its logarithm diverges. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Matched |
| =GAMMALN(-1) | A negative argument, also excluded | #NUM! | #NUM!ProvenanceExcel documents: "If x <= 0, GAMMALN returns the #NUM! error value." Note this is a STRICTER domain than GAMMA's: GAMMA(-3.75) is a documented finite value, but GAMMALN(-3.75) is excluded outright, because the gamma function alternates sign on the negative axis and its real logarithm would be undefined half the time. Asserted separately from the zero case for that reason. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Matched |
| =GAMMALN("abc") | A non-numeric argument | #VALUE! | #VALUE!ProvenanceExcel documents: "If x is nonnumeric, GAMMALN returns the #VALUE! error value." |
Matched |
LibreOffice Calc 25.8.7.3 (tested 2026-08-31)
| Formula | Description | Result | Expected | Verdict |
|---|---|---|---|---|
| =ROUND(GAMMALN(4),12) | Microsoft's documented worked example: the natural logarithm of the gamma function at 4 | 1.791759469228 | 1.791759469228ProvenanceMicrosoft publishes '=GAMMALN(4)' with the result 1.7917595. Derived independently two ways that agree to every digit mpmath prints at 50 places: mpmath's loggamma(4) = 1.7917594692280550008, and -- using the page's own stated identity that "The number e raised to the GAMMALN(i) power, where i is an integer, returns the same result as (i - 1)!" -- ln(3!) = ln(6) = 1.7917594692280550008. Rounds to exactly the published 1.7917595 at the 7 dp the page prints; asserted at 12 dp because that is still comfortably inside double precision. |
Matched |
| =ROUND(EXP(GAMMALN(6)),9) | The page's own identity: e raised to GAMMALN(i) is (i-1)! | 120 | 120ProvenanceMicrosoft states: "The number e raised to the GAMMALN(i) power, where i is an integer, returns the same result as (i - 1)!". At i = 6 that is 5! = 120, an exact integer. Asserted as EXP(...) inside the engine so it exercises the log-gamma implementation against a value that is known exactly, rather than comparing two printed decimals. ROUND at 9 dp absorbs the round-trip through the exponential, which cannot be exact in binary floating point; 120 is recovered to far more than 9 decimals in the reference computation (mpmath: 119.99999999999999999997). |
Matched |
| =ROUND(GAMMALN(0.5)-LN(SQRT(PI())),12) | The classical value ln(Gamma(1/2)) = ln(sqrt(pi)), asserted as a difference of zero | 0 | 0ProvenanceNot a published example; the standard closed form, checked against the engine's own LN, SQRT and PI so that it tests the log-gamma implementation rather than a printed constant. mpmath at 50 digits: loggamma(0.5) = 0.57236494292470008707, and ln(sqrt(pi)) = 0.57236494292470008707. |
Matched |
| =GAMMALN(0) | Zero, which the page excludes | #VALUE! | #NUM!ProvenanceExcel documents: "If x <= 0, GAMMALN returns the #NUM! error value." Gamma has a pole at 0, so its logarithm diverges. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Mismatch |
| =GAMMALN(-1) | A negative argument, also excluded | #VALUE! | #NUM!ProvenanceExcel documents: "If x <= 0, GAMMALN returns the #NUM! error value." Note this is a STRICTER domain than GAMMA's: GAMMA(-3.75) is a documented finite value, but GAMMALN(-3.75) is excluded outright, because the gamma function alternates sign on the negative axis and its real logarithm would be undefined half the time. Asserted separately from the zero case for that reason. EXECUTED RESULT: all four LibreOffice builds (24.2.0.3, 24.8.7.2, 25.2.0.3, 25.8.7.3) return #VALUE! here instead of the documented #NUM! -- the same systemic #VALUE!-substitution pattern already recorded across this corpus, an error-code difference rather than a computation one. |
Mismatch |
| =GAMMALN("abc") | A non-numeric argument | #VALUE! | #VALUE!ProvenanceExcel documents: "If x is nonnumeric, GAMMALN returns the #VALUE! error value." |
Matched |
Docs & syntax
- Excel (desktop): official documentation
- Google Sheets: official documentation
- LibreOffice Calc: official documentation