Module gamma

Module gamma 

Source
Expand description

Gamma, Beta, Digamma, and Polygamma special functions with high-precision numerical evaluation.

Implements the Gamma function, Beta function, Digamma function, and Polygamma functions with comprehensive numerical evaluation support.

§Numerical Evaluation

Float inputs are automatically evaluated numerically using the Lanczos approximation (14-digit precision). Half-integer values are handled symbolically for exact results.

§Half-Integer Special Cases

The gamma function has exact symbolic forms for half-integers:

  • Γ(1/2) = √π
  • Γ(3/2) = √π/2
  • Γ(5/2) = 3√π/4
  • Γ(n+1/2) = (2n-1)!! · √π / 2^n

§Beta Function

The beta function B(a, b) = Γ(a)·Γ(b)/Γ(a+b) supports both symbolic and numerical evaluation. Float inputs are evaluated numerically using Lanczos gamma.

§Digamma Function

The digamma function ψ(z) = d/dz ln(Γ(z)) = Γ’(z)/Γ(z) is the logarithmic derivative of the gamma function. Special values are computed exactly.

§Polygamma Function

The polygamma function ψ^(n)(z) is the (n+1)-th derivative of ln(Γ(z)). ψ^(0) = digamma, ψ^(1) = trigamma, etc.

§Input Validation

All numerical functions validate inputs for NaN, infinity, and mathematical poles. Non-positive integers are poles for the gamma function and return infinity.

Functions§

gamma
Gamma function Γ(z)
lanczos_gamma
Lanczos approximation for Gamma function (for numerical evaluation)