Incomplete gamma function (source code)

= Incomplete gamma function
{title2=$\gamma(a,x),\Gamma(a,x)$}
{wiki}

For real $a>0$ and $x\geq0$, the lower and upper <incomplete gamma functions> are respectively
$$
\gamma(a,x)=\int_0^xt^{a-1}e^{-t}\,dt,\qquad\Gamma(a,x)=\int_x^\infty t^{a-1}e^{-t}\,dt.
$$
They divide the <Gamma function> integral at $x$, so $\gamma(a,x)+\Gamma(a,x)=\Gamma(a)$. The normalized ratios $P(a,x)=\gamma(a,x)/\Gamma(a)$ and $Q(a,x)=\Gamma(a,x)/\Gamma(a)$ sum to1. Lowercase $\gamma$ and uppercase $\Gamma$ distinguish the two tails; using one symbol for both would reverse which part is omitted.<NIST Digital Library of Mathematical Functions>[section8.2(i), equations8.2.1–8.2.5]{ref}

For example, $\gamma(1,x)=1-e^{-x}$ and $\Gamma(1,x)=e^{-x}$. Thus $P$ is the cumulative probability and $Q$ the tail probability for a <gamma distribution> of unit scale. <Integration by parts> gives $\Gamma(a+1,x)=a\Gamma(a,x)+x^ae^{-x}$, a recurrence useful for both numerical evaluation and endpoint <asymptotic expansions>.