search

Found

info Overview

Enter x (0.5-170) to compute Γ(x) via a 5-term Stirling series, plus log₁₀ Γ(x) and the relative gain the correction terms add over the leading term.

📘 How to Use

  1. Set x (0.5 to 170) with the slider or the number field
  2. Read the four outputs: Γ(x) 5-term, log₁₀ Γ(x), leading term, and correction gain
  3. Compare the leading term against the 5-term value to see how much the series adds

Gamma Function Stirling Approximation Calculator

5.0

Slider from 0.5 to 50 in 0.1 steps

0.5 to 170

※ Refined: Γ(x) ≈ √(2π/x)·(x/e)ˣ·(1 + 1/12x + 1/288x² − 139/51840x³ − 571/2488320x⁴)

※ Relative error drops below 10⁻⁶ for x ≥ 5

Γ(x) 5-term
24.0000

Five-term Stirling-series approximation

log₁₀ Γ(x)
1.3802
Γ(x) leading term
23.6038

Just √(2π/x)·(x/e)ˣ

Series-correction gain
1.6784 %
Copied!
Article

Gamma Function Stirling Approximation Calculator | Γ(x) and log Γ(x) from a 5-term series

Compute Γ(x) for any real x ≥ 0.5 using a five-term Stirling series, alongside log₁₀ Γ(x), the bare leading term √(2π/x)·(x/e)ˣ, and the percentage gain the correction terms contribute.

💡 About this tool

The gamma function extends the factorial to non-integers, with Γ(n) = (n−1)!. If you have ever needed Γ(7.3) and reached for Stirling's formula, you know the bare leading term is fine for large arguments but drifts noticeably for small x. Most online gamma calculators just hand you a single number with no sense of where that number came from or how trustworthy it is.

This tool keeps both versions on screen at once. It computes the leading term √(2π/x)·(x/e)ˣ and the refined value with the asymptotic series 1 + 1/12x + 1/288x² − 139/51840x³ − 571/2488320x⁴, then prints the difference as a correction-gain percentage. That makes the series visible: you can watch the correction shrink as x grows and verify that for x ≥ 5 the relative error falls below 10⁻⁶. For large arguments the value is taken through a log path to report log₁₀ Γ(x) without overflowing.

🧐 Frequently Asked Questions

Does an integer x give me a factorial? Yes. Because Γ(n) = (n−1)!, entering x=5 returns Γ(5) = 4! = 24. Integers are handy for sanity-checking the approximation against an exact value.

Why does x start at 0.5? Stirling's asymptotic series is least accurate for small arguments. Below 0.5 even five terms lose precision, so 0.5 is set as a practical floor.

Why does the number field reach 170 but the slider stops at 50? Γ(x) grows explosively and overflows IEEE double precision near x ≈ 171. The slider stays at 50 for smooth dragging; the number field handles the larger range up to 170.

Can the correction gain be negative? No. The third and fourth coefficients are negative, but the leading 1/12x term dominates across the supported range (x ≥ 0.5), so the improved value always sits just above the basic term and the gain stays positive — about +15% at x = 0.5, shrinking toward 0 as x grows.

What is log₁₀ Γ(x) good for? When Γ(x) reaches astronomical magnitudes, the order of magnitude is more useful than the raw value. Log-gamma turns up constantly in log-likelihoods for probability distributions and large combinatorics.

📚 Fun Facts

Stirling's formula carries the name of James Stirling, but Abraham de Moivre derived the leading asymptotic part first, which is why some texts call it the de Moivre–Stirling formula. The denominators in the correction — 12, 288, 51840 — descend from Bernoulli numbers, and the series is famously divergent: it never converges no matter how many terms you add. For a given x there is an optimal place to truncate, and pushing past it actually makes the answer worse, a hallmark of asymptotic expansions.