All formulas

Special functions

Gamma function

special.gammaAlso called gamma, euler gamma function, gamma function, tgamma

Γ(x)=∫0∞tx−1e−t dt\Gamma(x) = \int_{0}^{\infty} t^{x - 1} e^{-t}\,dt

Euler's integral, the continuous extension of the factorial: Γ(n) = (n − 1)! for whole n, and Γ(x + 1) = x Γ(x) for every x > 0.

Notation

xx

the argument

x > 0

Γ(x)\Gamma(x)

Result: the gamma function

scalar

Worked examples

Each result is solved exactly and confirmed by two independent computations.

  1. Given

    x=5x = 5

    Result

    Γ(x)=24\displaystyle \Gamma(x) = 24
  2. Given

    x=1/2x = 1/2

    Result

    Γ(x)=π\displaystyle \Gamma(x) = \sqrt{\pi}

    ≈ 1.77245385091

  3. Given

    x=5/2x = 5/2

    Result

    Γ(x)=3π4\displaystyle \Gamma(x) = \frac{3 \sqrt{\pi}}{4}

    ≈ 1.32934038818

Common mistakes

  • Returns x! instead of (x − 1)!

    The result is Γ(x + 1) = x Γ(x), too large by a factor of x.

    Fix: Γ(x) = (x − 1)!; evaluate gamma at x, or the factorial at x − 1.

  • Uses Stirling's approximation as the value

    √(2π/x) (x/e)x is only the leading term of an asymptotic series; its relative error is about 1/(12x), already 1% at x = 8.

    Fix: Use a library gamma function, or add the correction terms and shift small arguments upward first.

Source

  • DLMF, eq. 5.2.1

    NIST Digital Library of Mathematical Functions. https://dlmf.nist.gov/ Release 1.2.8 of 2026-09-15. F. W. J. Olver, A. B. Olde Daalhuis, D. W. Lozier, B. I. Schneider, R. F. Boisvert, C. W. Clark, B. R. Miller, B. V. Saunders, H. S. Cohl, and M. A. McClain, eds.

    dlmf.nist.gov