What is the incomplete gamma function?
The incomplete gamma function generalizes the ordinary (complete) gamma function by stopping the integral at a finite point instead of integrating all the way to infinity. The lower incomplete gamma function \(\gamma(a,x)\) integrates \(t^{a-1} e^{-t}\) from 0 up to \(x\), while the upper incomplete gamma function \(\Gamma(a,x)\) integrates from \(x\) out to infinity. Both depend on a shape parameter \(a\) and an argument \(x\), and both are pure dimensionless real numbers. They appear constantly in statistics (the chi-square and gamma distribution CDFs), physics, reliability engineering and queueing theory.
How to use this calculator
Enter the shape parameter a (must be positive, \(a > 0\)) and the argument x (must be non-negative, \(x \ge 0\)). The calculator returns \(\gamma(a,x)\), \(\Gamma(a,x)\), and the complete gamma function \(\Gamma(a)\) so you can confirm the identity $$\gamma(a,x) + \Gamma(a,x) = \Gamma(a)$$ At \(x = 0\) the lower function is 0 and the upper equals \(\Gamma(a)\); as \(x\) grows large the lower function approaches \(\Gamma(a)\) and the upper approaches 0.
The formula and algorithm
The defining integrals are $$\gamma(a,x) = \int_{0}^{x} t^{a-1} e^{-t}\, dt$$ and $$\Gamma(a,x) = \int_{x}^{\infty} t^{a-1} e^{-t}\, dt$$ of the same integrand. To evaluate them stably, this tool uses the regularized forms \(P(a,x) = \gamma(a,x)/\Gamma(a)\) and \(Q(a,x) = \Gamma(a,x)/\Gamma(a)\). When \(x < a+1\) a rapidly converging power series gives \(P\); otherwise a Lentz continued fraction gives \(Q\). The complete gamma \(\Gamma(a)\) is obtained from a Lanczos approximation of \(\ln \Gamma(a)\). This is the classic Numerical Recipes gammp/gammq split, accurate to roughly 15 significant digits in double precision.
Worked example
Take \(a = 1\) and \(x = 2\). Because \(t^{a-1} = t^0 = 1\), the lower function is the integral of \(e^{-t}\) from 0 to 2 $$= 1 - e^{-2} = 1 - 0.13533528 = 0.86466472$$ The upper function is \(e^{-2} = 0.13533528\), and \(\Gamma(1) = 1\). The identity check $$0.86466472 + 0.13533528 = 1.0$$ confirms the result.
FAQ
Why must a be positive? The convergent definitions and the Lanczos ln-gamma evaluation require \(a > 0\); at non-positive integers \(\Gamma(a)\) has poles.
What if x is 0? \(\gamma(a,0) = 0\) and \(\Gamma(a,0) = \Gamma(a)\), so the upper function equals the complete gamma function.
How accurate is the result? Double-precision arithmetic and the series/continued-fraction split deliver about 15 significant figures across the valid domain.