Gamma Function Γ(s) Calculator (Numerical Integration)
Compute the gamma function Γ(s), the integral of t^(s-1) e^(-t) from 0 to infinity. Enter a positive real s to get Γ(s), lnΓ(s), its link to factorials, and a direct double-exponential integration reference value.
Input
Enter a positive real number s to numerically compute the gamma function Γ(s), the integral of t^(s-1) e^(-t) for t from 0 to infinity.
Example: s = 5 gives Γ(5) = 4! = 24. Decimals such as 0.5 or 3.5 are allowed.
Result
Γ(5)
24
Γ(s) = integral of t^(s-1) e^(-t) dt from 0 to infinity
lnΓ(s) (natural log)
3.1780538303
4! = (s-1)!
24
Direct numerical integral
24
Accuracy check
The half-infinite range was integrated directly with a double-exponential (tanh-sinh) change of variables using 2,049 sample points. The relative difference from the Lanczos approximation is 2.960595e-16.
Since s = 5 is an integer, Γ(s) equals 4! (factorial).
How it works
- The gamma function is the special function defined as Γ(s) = the integral of t^(s-1) e^(-t) over t from 0 to infinity. The integral converges for s > 0.
- For a positive integer n, Γ(n) = (n-1)! holds. For example Γ(5) = 4! = 24 and Γ(1) = 0! = 1. It generalizes the factorial to real and complex arguments.
- This tool evaluates Γ(s) and lnΓ(s) with a high-accuracy Lanczos approximation. The log-gamma value lnΓ(s) helps avoid overflow when the result grows very large.
- As a reference it also maps the half-infinite integral to a finite sum using a double-exponential (tanh-sinh) change of variables and integrates directly with the trapezoidal rule, then reports the relative difference between the two so you can check accuracy.
- Very large s lets the tail stretch out and reduces integration accuracy, so the input s has an upper bound. Values of s at or below 0 are out of scope because this integral definition does not converge there.
Reviews
Tell us what you think of this calculator.
Write a review
- Home
Gamma Function Γ(s) Calculator (Numerical Integration)