# Gamma function

In mathematics, the gamma function (represented by Γ, capital Greek letter gamma) is the most common extension of the factorial function to complex numbers. Derived by Daniel Bernoulli, the gamma function $\Gamma (z)$ is defined for all complex numbers $z$ except non-positive integers, and for every positive integer $z=n$, $\Gamma (n)=(n-1)!\,.$The gamma function can be defined via a convergent improper integral for complex numbers with positive real part:
$\Gamma (z)=\int _{0}^{\infty }t^{z-1}e^{-t}{\text{ d}}t,\ \qquad \Re (z)>0\,.$The gamma function then is defined in the complex plane as the analytic continuation of this integral function: it is a meromorphic function which is holomorphic except at zero and the negative integers, where it has simple poles.
The gamma function has no zeros, so the reciprocal gamma function ⁠1/Γ(z)⁠ is an entire function. In fact, the gamma function corresponds to the Mellin transform of the negative exponential function:
$\Gamma (z)={\mathcal {M}}\{e^{-x}\}(z)\,.$
Other extensions of the factorial function do exist, but the gamma function is the most popular and useful. It appears as a factor in various probability-distribution functions and other formulas in the fields of probability, statistics, analytic number theory, and combinatorics.

## Motivation

The gamma function can be seen as a solution to the interpolation problem of finding a smooth curve $y=f(x)$ that connects the points of the factorial sequence: $(x,y)=(n,n!)$ for all positive integer values of $n$. The simple formula for the factorial, x! = 1 × 2 × ⋯ × x is only valid when x is a positive integer, and no elementary function has this property, but a good solution is the gamma function $f(x)=\Gamma (x+1)$.
The gamma function is not only smooth but analytic (except at the non-positive integers), and it can be defined in several explicit ways. However, it is not the only analytic function that extends the factorial, as one may add any analytic function that is zero on the positive integers, such as $k\sin(m\pi x)$ for an integer $m$. Such a function is known as a pseudogamma function, the most famous being the Hadamard function.
A more restrictive requirement is the functional equation which interpolates the shifted factorial $f(n)=(n{-}1)!$ : $f(x+1)=xf(x)\ {\text{ for all }}x>0,\qquad f(1)=1.$
But this still does not give a unique solution, since it allows for multiplication by any periodic function $g(x)$ with $g(x)=g(x+1)$ and $g(0)=1$, such as $g(x)=e^{k\sin(m\pi x)}$.
One way to resolve the ambiguity is the Bohr–Mollerup theorem, which shows that $f(x)=\Gamma (x)$ is the unique interpolating function for the factorial, defined over the positive reals, which is logarithmically convex, meaning that $y=\log f(x)$ is convex.

## Definition
### Main definition

The notation $\Gamma (z)$ is due to Legendre. If the real part of the complex number z is strictly positive ($\Re (z)>0$), then the integral $\Gamma (z)=\int _{0}^{\infty }t^{z-1}e^{-t}\,dt$ converges absolutely, and is known as the Euler integral of the second kind. (Euler's integral of the first kind is the beta function.) Using integration by parts, one sees that:
${\begin{aligned}\Gamma (z+1)&=\int _{0}^{\infty }t^{z}e^{-t}\,dt\\&={\Bigl-t^{z}e^{-t}{\Bigr ]}_{0}^{\infty }+\int _{0}^{\infty }zt^{z-1}e^{-t}\,dt\\&=\lim _{t\to \infty }\left(-t^{z}e^{-t}\right)-\left(-0^{z}e^{-0}\right)+z\int _{0}^{\infty }t^{z-1}e^{-t}\,dt.\end{aligned}}$
Recognizing that $-t^{z}e^{-t}\to 0$ as $t\to \infty ,$ ${\begin{aligned}\Gamma (z+1)&=z\int _{0}^{\infty }t^{z-1}e^{-t}\,dt\\&=z\Gamma (z).\end{aligned}}$
Then $\Gamma (1)$ can be calculated as: ${\begin{aligned}\Gamma (1)&=\int _{0}^{\infty }t^{1-1}e^{-t}\,dt\\&=\int _{0}^{\infty }e^{-t}\,dt\\&=1.\end{aligned}}$
Thus we can show that $\Gamma (n)=(n-1)!$ for any positive integer n by induction. Specifically, the base case is that $\Gamma (1)=1=0!$, and the induction step is that $\Gamma (n+1)=n\Gamma (n)=n(n-1)!=n!.$
The identity Γ(z)=(Γ(z+1))/z {\textstyle \Gamma (z)={\frac {\Gamma (z+1)}{z}}} can be used (or, yielding the same result, analytic continuation can be used) to uniquely extend the integral formulation for $\Gamma (z)$ to a meromorphic function defined for all complex numbers z, except integers less than or equal to zero. It is this extended version that is commonly referred to as the gamma function.

### Alternative definitions

There are many equivalent definitions.

#### Euler's definition as an infinite product

For a fixed integer $m$, as the integer $n$ increases, we have that $\lim _{n\to \infty }{\frac {n!\,\left(n+1\right)^{m}}{(n+m)!}}=1\,.$
If $m$ is not an integer, then this equation is meaningless, since in this section the factorial of a non-integer has not been defined yet. However, let us assume that this equation continues to hold when $m$ is replaced by an arbitrary complex number $z$, in order to define the Gamma function for non-integers:
$\lim _{n\to \infty }{\frac {n!\,\left(n+1\right)^{z}}{(n+z)!}}=1\,.$ Multiplying both sides by $(z-1)!$ gives ${\begin{aligned}(z-1)!&={\frac {1}{z}}\lim _{n\to \infty }n!{\frac {z!}{(n+z)!}}(n+1)^{z}\\[8pt]&={\frac {1}{z}}\lim _{n\to \infty }(1\cdot 2\cdots n){\frac {1}{(1+z)\cdots (n+z)}}\left({\frac {2}{1}}\cdot {\frac {3}{2}}\cdots {\frac {n+1}{n}}\right)^{z}\\[8pt]&={\frac {1}{z}}\prod _{n=1}^{\infty }\left[{\frac {1}{1+{\frac {z}{n}}}}\left(1+{\frac {1}{n}}\right)^{z}\right].\end{aligned}}$This infinite product, which is due to Euler, converges for all complex numbers $z$ except the non-positive integers, which fail because of a division by zero. In fact, the above assumption produces a unique definition of $\Gamma (z)$ as ⁠$(z-1)!$⁠.
Intuitively, this formula indicates that $\Gamma (z)$ is approximately the result of computing $\Gamma (n+1)=n!$ for some large integer $n$, multiplying by $(n+1)^{z}$ to approximate $\Gamma (n+z+1)$, and then multiplying by ${\frac {(z-1)!}{(n+z)!}}$ to use the relationship $\Gamma (x+1)=x\Gamma (x)$ backwards $n+1$ times to get an approximation for $\Gamma (z)$; and furthermore that this approximation becomes exact as $n$ increases to infinity.
The infinite product for the reciprocal ${\frac {1}{\Gamma (z)}}=z\prod _{n=1}^{\infty }\left[\left(1+{\frac {z}{n}}\right)/{\left(1+{\frac {1}{n}}\right)^{z}}\right]$ is an entire function, converging for every complex number z.

#### Weierstrass's definition

The definition for the gamma function due to Weierstrass is also valid for all complex numbers $z$ except non-positive integers: $\Gamma (z)={\frac {e^{-\gamma z}}{z}}\prod _{n=1}^{\infty }\left(1+{\frac {z}{n}}\right)^{-1}e^{z/n},$ where $\gamma \approx 0.577216$ is the Euler–Mascheroni constant. This is the Hadamard product of $1/\Gamma (z)$ in a rewritten form.

## Properties
### General

Besides the fundamental property discussed above: $\Gamma (z+1)=z\ \Gamma (z)$ other important functional equations for the gamma function are Euler's reflection formula $\Gamma (1-z)\Gamma (z)={\frac {\pi }{\sin \pi z}},\qquad z\not \in \mathbb {Z}$ which implies $\Gamma (z-n)=(-1)^{n-1}\;{\frac {\Gamma (-z)\Gamma (1+z)}{\Gamma (n+1-z)}},\qquad n\in \mathbb {Z}$ and the Legendre duplication formula $\Gamma (z)\Gamma \left(z+{\tfrac {1}{2}}\right)=2^{1-2z}\;{\sqrt {\pi }}\;\Gamma (2z).$
The duplication formula is a special case of the multiplication theorem (see Eq. 5.5.6): $\prod _{k=0}^{m-1}\Gamma \left(z+{\frac {k}{m}}\right)=(2\pi )^{\frac {m-1}{2}}\;m^{{\frac {1}{2}}-mz}\;\Gamma (mz).$
A simple but useful property, which can be seen from the limit definition, is: ${\overline {\Gamma (z)}}=\Gamma ({\overline {z}})\;\Rightarrow \;\Gamma (z)\Gamma ({\overline {z}})\in \mathbb {R} .$
In particular, with z = a + bi, this product is $|\Gamma (a+bi)|^{2}=|\Gamma (a)|^{2}\prod _{k=0}^{\infty }{\frac {1}{1+{\frac {b^{2}}{(a+k)^{2}}}}}$
If the real part is an integer or a half-integer, this can be finitely expressed in closed form: ${\begin{aligned}|\Gamma (bi)|^{2}&={\frac {\pi }{b\sinh \pi b}}\\[1ex]\left|\Gamma \left({\tfrac {1}{2}}+bi\right)\right|^{2}&={\frac {\pi }{\cosh \pi b}}\\[1ex]\left|\Gamma \left(1+bi\right)\right|^{2}&={\frac {\pi b}{\sinh \pi b}}\\[1ex]\left|\Gamma \left(1+n+bi\right)\right|^{2}&={\frac {\pi b}{\sinh \pi b}}\prod _{k=1}^{n}\left(k^{2}+b^{2}\right),\quad n\in \mathbb {N} \\[1ex]\left|\Gamma \left(-n+bi\right)\right|^{2}&={\frac {\pi }{b\sinh \pi b}}\prod _{k=1}^{n}\left(k^{2}+b^{2}\right)^{-1},\quad n\in \mathbb {N} \\[1ex]\left|\Gamma \left({\tfrac {1}{2}}\pm n+bi\right)\right|^{2}&={\frac {\pi }{\cosh \pi b}}\prod _{k=1}^{n}\left(\left(k-{\tfrac {1}{2}}\right)^{2}+b^{2}\right)^{\pm 1},\quad n\in \mathbb {N} \\[-1ex]&\end{aligned}}$
Perhaps the best-known value of the gamma function at a non-integer argument is $\Gamma \left({\tfrac {1}{2}}\right)={\sqrt {\pi }},$ which can be found by setting z=1/2 {\textstyle z={\frac {1}{2}}} in the reflection or duplication formulas, by using the relation to the beta function given below with z$_1$=z$_2$=1/2 {\textstyle z_{1}=z_{2}={\frac {1}{2}}}, or simply by making the substitution $u={\sqrt {z}}$ in the integral definition of the gamma function, resulting in a Gaussian integral. In general, for non-negative integer values of $n$ we have: ${\begin{aligned}\Gamma \left({\tfrac {1}{2}}+n\right)&={(2n)! \over 4^{n}n!}{\sqrt {\pi }}={\frac {(2n-1)!!}{2^{n}}}{\sqrt {\pi }}={\binom {n-{\frac {1}{2}}}{n}}n!{\sqrt {\pi }}\\[8pt]\Gamma \left({\tfrac {1}{2}}-n\right)&={(-4)^{n}n! \over (2n)!}{\sqrt {\pi }}={\frac {(-2)^{n}}{(2n-1)!!}}{\sqrt {\pi }}={\frac {\sqrt {\pi }}{{\binom {-1/2}{n}}n!}}\end{aligned}}$ where the double factorial $(2n-1)!!=(2n-1)(2n-3)\cdots (3)(1)$. See Particular values of the gamma function for calculated values.
It might be tempting to generalize the result that Γ(1/2)=√π{\textstyle \Gamma \left({\frac {1}{2}}\right)={\sqrt {\pi }}} by looking for a formula for other individual values $\Gamma (r)$ where $r$ is rational, especially because according to Gauss's digamma theorem, it is possible to do so for the closely related digamma function at every rational value. However, these numbers $\Gamma (r)$ are not known to be expressible by themselves in terms of elementary functions. It has been proved that $\Gamma (n+r)$ is a transcendental number and algebraically independent of $\pi$ for any integer $n$ and each of the fractions r=1/6, 1/4, 1/3, 2/3, 3/4, 5/6 {\textstyle r={\frac {1}{6}}, {\frac {1}{4}}, {\frac {1}{3}}, {\frac {2}{3}}, {\frac {3}{4}}, {\frac {5}{6}}}. In general, when computing values of the gamma function, we must settle for numerical approximations.
The derivatives of the gamma function are described in terms of the polygamma function, ψ$^{(0)}$(z): $\Gamma '(z)=\Gamma (z)\psi ^{(0)}(z).$ For a positive integer m the derivative of the gamma function can be calculated as follows:
$\Gamma '(m+1)=m!\left(-\gamma +\sum _{k=1}^{m}{\frac {1}{k}}\right)=m!\left(-\gamma +H(m)\right)\,,$ where H(m) is the mth harmonic number and γ is the Euler–Mascheroni constant.
For $\Re (z)>0$ the $n$th derivative of the gamma function is: ${\frac {d^{n}}{dz^{n}}}\Gamma (z)=\int _{0}^{\infty }t^{z-1}e^{-t}(\log t)^{n}\,dt.$ (This can be derived by differentiating the integral form of the gamma function with respect to $z$, and using the technique of differentiation under the integral sign.)
Using the identity $\Gamma ^{(n)}(1)=(-1)^{n}B_{n}(\gamma ,1!\zeta (2),\ldots ,(n-1)!\zeta (n))$ where $\zeta (z)$ is the Riemann zeta function, and $B_{n}$ is the $n$-th Bell polynomial, we have in particular the Laurent series expansion of the gamma function $\Gamma (z)={\frac {1}{z}}-\gamma +{\frac {1}{2}}\left(\gamma ^{2}+{\frac {\pi ^{2}}{6}}\right)z-{\frac {1}{6}}\left(\gamma ^{3}+{\frac {\gamma \pi ^{2}}{2}}+2\zeta (3)\right)z^{2}+O(z^{3}).$

### Inequalities

When restricted to the positive real numbers, the gamma function is a strictly logarithmically convex function. This property may be stated in any of the following three equivalent ways:
* For any two positive real numbers $x_{1}$ and $x_{2}$, and for any $t\in [0,1]$, $\Gamma (tx_{1}+(1-t)x_{2})\leq \Gamma (x_{1})^{t}\Gamma (x_{2})^{1-t}.$
* For any two positive real numbers $x_{1}$ and $x_{2}$, and $x_{2}$ > $x_{1}$$\left({\frac {\Gamma (x_{2})}{\Gamma (x_{1})}}\right)^{\frac {1}{x_{2}-x_{1}}}>\exp \left({\frac {\Gamma '(x_{1})}{\Gamma (x_{1})}}\right).$
* For any positive real number $x$, $\Gamma ''(x)\Gamma (x)>\Gamma '(x)^{2}.$
The last of these statements is, essentially by definition, the same as the statement that $\psi ^{(1)}(x)>0$, where $\psi ^{(1)}$ is the polygamma function of order 1. To prove the logarithmic convexity of the gamma function, it therefore suffices to observe that $\psi ^{(1)}$ has a series representation which, for positive real x, consists of only positive terms.
Logarithmic convexity and Jensen's inequality together imply, for any positive real numbers $x_{1},\ldots ,x_{n}$ and $a_{1},\ldots ,a_{n}$, $\Gamma \left({\frac {a_{1}x_{1}+\cdots +a_{n}x_{n}}{a_{1}+\cdots +a_{n}}}\right)\leq {\bigl\Gamma (x_{1})^{a_{1}}\cdots \Gamma (x_{n})^{a_{n}}{\bigr )}^{\frac {1}{a_{1}+\cdots +a_{n}}}.$
There are also bounds on ratios of gamma functions. The best-known is Gautschi's inequality, which says that for any positive real number x and any s ∈ (0, 1), $x^{1-s}<{\frac {\Gamma (x+1)}{\Gamma (x+s)}}<\left(x+1\right)^{1-s}.$

### Stirling's formula

The behavior of $\Gamma (x)$ for an increasing positive real variable is given by Stirling's formula $\Gamma (x+1)\sim {\sqrt {2\pi x}}\left({\frac {x}{e}}\right)^{x},$ where the symbol $\sim$ means asymptotic convergence: the ratio of the two sides converges to 1 in the limit x→+∞{\textstyle x\to +\infty }. This growth is faster than exponential, $\exp(\beta x)$, for any fixed value of $\beta$.
Another useful limit for asymptotic approximations for $x\to +\infty$ is: ${\Gamma (x+\alpha )}\sim {\Gamma (x)x^{\alpha }},\qquad \alpha \in \mathbb {C} .$
When writing the error term as an infinite product, Stirling's formula can be used to define the gamma function: $\Gamma (x)={\sqrt {\frac {2\pi }{x}}}\left({\frac {x}{e}}\right)^{x}\prod _{n=0}^{\infty }\left[{\frac {1}{e}}\left(1+{\frac {1}{x+n}}\right)^{x+n+{\frac {1}{2}}}\right]$

### Extension to negative, non-integer values

Although the main definition of the gamma function—the Euler integral of the second kind—is only valid (on the real axis) for positive arguments, its domain can be extended with analytic continuation to negative arguments by shifting the negative argument to positive values by using either the Euler's reflection formula, $\Gamma (-x)={\frac {1}{\Gamma (x+1)}}{\frac {\pi }{\sin {\big\pi (x+1){\big )}}},$ or the fundamental property, $\Gamma (-x):={\frac {1}{-x}}\Gamma (-x+1),$ when $x\not \in \mathbb {Z}$. For example, $\Gamma \left(-{\frac {1}{2}}\right)=-2\Gamma \left({\frac {1}{2}}\right).$

### Residues

The behavior for non-positive $z$ is more intricate. Euler's integral does not converge for $\Re (z)\leq 0$, but the function it defines in the positive complex half-plane has a unique analytic continuation to the negative half-plane. One way to find that analytic continuation is to use Euler's integral for positive arguments and extend the domain to negative numbers by repeated application of the recurrence formula, $\Gamma (z)={\frac {\Gamma (z+n+1)}{z(z+1)\cdots (z+n)}},$ choosing $n$ such that $z+n$ is positive. The product in the denominator is zero when $z$ equals any of the integers $0,-1,-2,\ldots$. Thus, the gamma function must be undefined at those points to avoid division by zero; it is a meromorphic function with simple poles at the non-positive integers.
For a function $f$ of a complex variable $z$, at a simple pole $c$, the residue of $f$ is given by: $\operatorname {Res} (f,c)=\lim _{z\to c}(z-c)f(z).$
For the simple pole $z=-n$, the recurrence formula can be rewritten as: $(z+n)\Gamma (z)={\frac {\Gamma (z+n+1)}{z(z+1)\cdots (z+n-1)}}.$ The numerator at $z=-n,$ is $\Gamma (z+n+1)=\Gamma (1)=1$ and the denominator $z(z+1)\cdots (z+n-1)=-n(1-n)\cdots (n-1-n)=(-1)^{n}n!.$ So the residues of the gamma function at those points are: $\operatorname {Res} (\Gamma ,-n)={\frac {(-1)^{n}}{n!}}.$The gamma function is non-zero everywhere along the real line, although it comes arbitrarily close to zero as z → −∞. There is in fact no complex number $z$ for which $\Gamma (z)=0$, and hence the reciprocal gamma function 1/Γ(z) {\textstyle {\frac {1}{\Gamma (z)}}} is an entire function, with zeros at $z=0,-1,-2,\ldots$.

### Minima and maxima

On the real line, the gamma function has a local minimum at z$_{min}$ ≈ +1.46163214496836234126 where it attains the value Γ(z$_{min}$) ≈ +0.88560319441088870027. The gamma function rises to either side of this minimum. The solution to Γ(z − 0.5) = Γ(z + 0.5) is z = +1.5 and the common value is Γ(1) = Γ(2) = +1. The positive solution to Γ(z − 1) = Γ(z + 1) is z = φ ≈ +1.618, the golden ratio, and the common value is Γ(φ − 1) = Γ(φ + 1) = φ! ≈ +1.44922960226989660037.
The gamma function must alternate sign between its poles at the non-positive integers because the product in the forward recurrence contains an odd number of negative factors if the number of poles between $z$ and $z+n$ is odd, and an even number if the number of poles is even. The values at the local extrema of the gamma function along the real axis between the non-positive integers are:
    Γ(−0.50408300826445540925...) = −3.54464361115500508912...,
    Γ(−1.57349847316239045877...) = 2.30240725833968013582...,
    Γ(−2.61072086844414465000...) = −0.88813635840124192009...,
    Γ(−3.63529336643690109783...) = 0.24512753983436625043...,
    Γ(−4.65323776174314244171...) = −0.05277963958731940076..., etc.

### Integral representations

There are many formulas, besides the Euler integral of the second kind, that express the gamma function as an integral. For instance, when the real part of z is positive, $\Gamma (z)=\int _{-\infty }^{\infty }e^{zt-e^{t}}\,dt$ and $\Gamma (z)=\int _{0}^{1}\left(\log {\frac {1}{t}}\right)^{z-1}\,dt,$ $\Gamma (z)=2c^{z}\int _{0}^{\infty }t^{2z-1}e^{-ct^{2}}\,dt\,,\;c>0$ where the three integrals respectively follow from the substitutions $t=e^{-x}$, $t=-\log x$ and $t=cx^{2}$ in Euler's second integral. The last integral in particular makes clear the connection between the gamma function at half integer arguments and the Gaussian integral: if $z=1/2,\;c=1$ we get $\Gamma (1/2)=2\int _{0}^{\infty }e^{-t^{2}}\,dt={\sqrt {\pi }}\;.$
Binet's first integral formula for the gamma function states that, when the real part of z is positive, then: $\operatorname {log\Gamma } (z)=\left(z-{\frac {1}{2}}\right)\log z-z+{\frac {1}{2}}\log(2\pi )+\int _{0}^{\infty }\left({\frac {1}{2}}-{\frac {1}{t}}+{\frac {1}{e^{t}-1}}\right){\frac {e^{-tz}}{t}}\,dt.$ The integral on the right-hand side may be interpreted as a Laplace transform. That is, $\log \left(\Gamma (z)\left({\frac {e}{z}}\right)^{z}{\sqrt {\frac {z}{2\pi }}}\right)={\mathcal {L}}\left({\frac {1}{2t}}-{\frac {1}{t^{2}}}+{\frac {1}{t(e^{t}-1)}}\right)(z).$
Binet's second integral formula states that, again when the real part of z is positive, then: $\operatorname {log\Gamma } (z)=\left(z-{\frac {1}{2}}\right)\log z-z+{\frac {1}{2}}\log(2\pi )+2\int _{0}^{\infty }{\frac {\arctan(t/z)}{e^{2\pi t}-1}}\,dt.$
Let C be a Hankel contour, meaning a path that begins and ends at the point ∞ on the Riemann sphere, whose unit tangent vector converges to −1 at the start of the path and to 1 at the end, which has winding number 1 around 0, and which does not cross [0, ∞). Fix a branch of $\log(-t)$ by taking a branch cut along [0, ∞) and by taking $\log(-t)$ to be real when t is on the negative real axis. Assume z is not an integer. Then Hankel's formula for the gamma function is: $\Gamma (z)=-{\frac {1}{2i\sin \pi z}}\int _{C}(-t)^{z-1}e^{-t}\,dt,$ where $(-t)^{z-1}$ is interpreted as $\exp((z-1)\log(-t))$. The reflection formula leads to the closely related expression ${\frac {1}{\Gamma (z)}}={\frac {i}{2\pi }}\int _{C}(-t)^{-z}e^{-t}\,dt,$ again valid whenever z is not an integer.

### Continued fraction representation

The gamma function can also be represented by a sum of two continued fractions: ${\begin{aligned}\Gamma (z)&={\cfrac {e^{-1}}{2+0-z+1{\cfrac {z-1}{2+2-z+2{\cfrac {z-2}{2+4-z+3{\cfrac {z-3}{2+6-z+4{\cfrac {z-4}{2+8-z+5{\cfrac {z-5}{2+10-z+\ddots }}}}}}}}}}}}\\&+\ {\cfrac {e^{-1}}{z+0-{\cfrac {z+0}{z+1+{\cfrac {1}{z+2-{\cfrac {z+1}{z+3+{\cfrac {2}{z+4-{\cfrac {z+2}{z+5+{\cfrac {3}{z+6-\ddots }}}}}}}}}}}}}}\end{aligned}}$ where $z\in \mathbb {C}$.

### Fourier series expansion

The logarithm of the gamma function has the following Fourier series expansion for $0<z<1:$ $\operatorname {log\Gamma } (z)=\left({\frac {1}{2}}-z\right)(\gamma +\log 2)+(1-z)\log \pi -{\frac {1}{2}}\log \sin(\pi z)+{\frac {1}{\pi }}\sum _{n=1}^{\infty }{\frac {\log n}{n}}\sin(2\pi nz),$ which was for a long time attributed to Ernst Kummer, who derived it in 1847. However, Iaroslav Blagouchine discovered that Carl Johan Malmsten first derived this series in 1842.

### Raabe's formula

In 1840 Joseph Ludwig Raabe proved that $\int _{a}^{a+1}\log \Gamma (z)\,dz={\tfrac {1}{2}}\log 2\pi +a\log a-a,\quad a>0.$ In particular, if $a=0$ then $\int _{0}^{1}\log \Gamma (z)\,dz={\tfrac {1}{2}}\log 2\pi .$
The latter can be derived taking the logarithm in the above multiplication formula, which gives an expression for the Riemann sum of the integrand. Taking the limit for $a\to \infty$ gives the formula.

### Pi function

An alternative notation introduced by Gauss is the $\Pi$-function, a shifted version of the gamma function: $\Pi (z)=\Gamma (z+1)=z\Gamma (z)=\int _{0}^{\infty }e^{-t}t^{z}\,dt,$ so that $\Pi (n)=n!$ for every non-negative integer $n$.
Using the pi function, the reflection formula is: $\Pi (z)\Pi (-z)={\frac {\pi z}{\sin(\pi z)}}={\frac {1}{\operatorname {sinc} (z)}}$ using the normalized sinc function; while the multiplication theorem becomes: $\Pi \left({\frac {z}{m}}\right)\,\Pi \left({\frac {z-1}{m}}\right)\cdots \Pi \left({\frac {z-m+1}{m}}\right)=(2\pi )^{\frac {m-1}{2}}m^{-z-{\frac {1}{2}}}\Pi (z)\ .$
The shifted reciprocal gamma function is sometimes denoted π(z)=1/Π(z) , {\textstyle \pi (z)={\frac {1}{\Pi (z)}}\ , } an entire function.
The volume of an n-ellipsoid with radii r$_1$, …, r$_n$ can be expressed as $V_{n}(r_{1},\dotsc ,r_{n})={\frac {\pi ^{\frac {n}{2}}}{\Pi \left({\frac {n}{2}}\right)}}\prod _{k=1}^{n}r_{k}.$

### Relation to other functions

* In the first integral defining the gamma function, the limits of integration are fixed. The upper incomplete gamma function is obtained by allowing the lower limit of integration to vary:$\Gamma (z,x)=\int _{x}^{\infty }t^{z-1}e^{-t}dt.$There is a similar lower incomplete gamma function.
* The gamma function is related to Euler's beta function by the formula $\mathrm {B} (z_{1},z_{2})=\int _{0}^{1}t^{z_{1}-1}(1-t)^{z_{2}-1}\,dt={\frac {\Gamma (z_{1})\,\Gamma (z_{2})}{\Gamma (z_{1}+z_{2})}}.$
* The logarithmic derivative of the gamma function is called the digamma function; higher derivatives are the polygamma functions.
* The analog of the gamma function over a finite field or a finite ring is the Gaussian sums, a type of exponential sum.
* The reciprocal gamma function is an entire function and has been studied as a specific topic.
* The gamma function also shows up in an important relation with the Riemann zeta function, $\zeta (z)$. $\pi ^{-{\frac {z}{2}}}\;\Gamma \left({\frac {z}{2}}\right)\zeta (z)=\pi ^{-{\frac {1-z}{2}}}\;\Gamma \left({\frac {1-z}{2}}\right)\;\zeta (1-z).$ It also appears in the following formula: $\zeta (z)\Gamma (z)=\int _{0}^{\infty }{\frac {u^{z-1}}{e^{u}-1}}\,{\frac {du}{u}},$ which is valid only for $\Re (z)>1$. The logarithm of the gamma function satisfies the following formula due to Lerch: $\operatorname {log\Gamma } (z)=\zeta _{H}'(0,z)-\zeta '(0),$ where $\zeta _{H}$ is the Hurwitz zeta function, $\zeta$ is the Riemann zeta function and the prime (′) denotes differentiation in the first variable.
* The gamma function is related to the stretched exponential function. For instance, the moments of that function are $\langle \tau ^{n}\rangle \equiv \int _{0}^{\infty }t^{n-1}\,e^{-\left({\frac {t}{\tau }}\right)^{\beta }}\,\mathrm {d} t={\frac {\tau ^{n}}{\beta }}\Gamma \left({n \over \beta }\right).$

### Particular values

Including up to the first 20 digits after the decimal point, some particular values of the gamma function are: ${\begin{array}{rcccl}\Gamma \left(-{\tfrac {3}{2}}\right)&=&{\tfrac {4{\sqrt {\pi }}}{3}}&\approx &+2.36327\,18012\,07354\,70306\\\Gamma \left(-{\tfrac {1}{2}}\right)&=&-2{\sqrt {\pi }}&\approx &-3.54490\,77018\,11032\,05459\\\Gamma \left({\tfrac {1}{2}}\right)&=&{\sqrt {\pi }}&\approx &+1.77245\,38509\,05516\,02729\\\Gamma (1)&=&0!&=&+1\\\Gamma \left({\tfrac {3}{2}}\right)&=&{\tfrac {\sqrt {\pi }}{2}}&\approx &+0.88622\,69254\,52758\,01364\\\Gamma (2)&=&1!&=&+1\\\Gamma \left({\tfrac {5}{2}}\right)&=&{\tfrac {3{\sqrt {\pi }}}{4}}&\approx &+1.32934\,03881\,79137\,02047\\\Gamma (3)&=&2!&=&+2\\\Gamma \left({\tfrac {7}{2}}\right)&=&{\tfrac {15{\sqrt {\pi }}}{8}}&\approx &+3.32335\,09704\,47842\,55118\\\Gamma (4)&=&3!&=&+6\end{array}}$ (These numbers can be found in the OEIS. The values presented here are truncated rather than rounded.) The complex-valued gamma function is undefined for non-positive integers, but in these cases the value can be defined in the Riemann sphere as ∞. The reciprocal gamma function is well defined and analytic at these values (and in the entire complex plane): ${\frac {1}{\Gamma (-3)}}={\frac {1}{\Gamma (-2)}}={\frac {1}{\Gamma (-1)}}={\frac {1}{\Gamma (0)}}=0.$

## Log-gamma function

Because the gamma and factorial functions grow so rapidly for moderately large arguments, many computing environments include a function that returns the natural logarithm of the gamma function, often given the name lgamma or lngamma in programming environments or gammaln in spreadsheets. This grows much more slowly, and for combinatorial calculations allows adding and subtracting logarithmic values instead of multiplying and dividing very large values. It is often defined as $\operatorname {log\Gamma } (z)=-\gamma z-\log z+\sum _{k=1}^{\infty }\left[{\frac {z}{k}}-\log \left(1+{\frac {z}{k}}\right)\right].$
The digamma function, which is the derivative of this function, is also commonly seen. In the context of technical and physical applications, e.g. with wave propagation, the functional equation $\operatorname {log\Gamma } (z)=\operatorname {log\Gamma } (z+1)-\log z$
is often used since it allows one to determine function values in one strip of width 1 in z from the neighbouring strip. In particular, starting with a good approximation for a z with large real part one may go step by step down to the desired z. Following an indication of Carl Friedrich Gauss, Rocktaeschel (1922) proposed for logΓ(z) an approximation for large Re(z): $\operatorname {log\Gamma } (z)\approx (z-{\tfrac {1}{2}})\log z-z+{\tfrac {1}{2}}\log(2\pi ).$
This can be used to accurately approximate logΓ(z) for z with a smaller Re(z) via (P.E.Böhmer, 1939) $\operatorname {log\Gamma } (z-m)=\operatorname {log\Gamma } (z)-\sum _{k=1}^{m}\log(z-k).$
A more accurate approximation can be obtained by using more terms from the asymptotic expansions of logΓ(z) and Γ(z), which are based on Stirling's approximation. $\Gamma (z)\sim z^{z-{\frac {1}{2}}}e^{-z}{\sqrt {2\pi }}\left(1+{\frac {1}{12z}}+{\frac {1}{288z^{2}}}-{\frac {139}{51\,840z^{3}}}-{\frac {571}{2\,488\,320z^{4}}}\right)$
    as |z| → ∞ at constant |arg(z)| < π. (See sequences A001163 and A001164 in the OEIS.)
In a more "natural" presentation: $\operatorname {log\Gamma } (z)=z\log z-z-{\tfrac {1}{2}}\log z+{\tfrac {1}{2}}\log 2\pi +{\frac {1}{12z}}-{\frac {1}{360z^{3}}}+{\frac {1}{1260z^{5}}}+o\left({\frac {1}{z^{5}}}\right)$
    as |z| → ∞ at constant |arg(z)| < π. (See sequences A046968 and A046969 in the OEIS.)
The coefficients of the terms with k > 1 of z$^{1−k}$ in the last expansion are simply ${\frac {B_{k}}{k(k-1)}}$ where the B$_k$ are the Bernoulli numbers.
The gamma function also has Stirling Series (derived by Charles Hermite in 1900) equal to $\operatorname {log\Gamma } (1+x)={\frac {x(x-1)}{2!}}\log(2)+{\frac {x(x-1)(x-2)}{3!}}(\log(3)-2\log(2))+\cdots ,\quad \Re (x)>0.$

### Properties

The Bohr–Mollerup theorem states that among all functions extending the factorial functions to the positive real numbers, only the gamma function is log-convex, that is, its natural logarithm is convex on the positive real axis. Another characterisation is given by the Wielandt theorem.
The gamma function is the unique function that simultaneously satisfies
* $\Gamma (1)=1$,
* $\Gamma (z+1)=z\Gamma (z)$ for all complex numbers $z$ except the non-positive integers, and,
* for integer n, lim$_{n→∞}$ (Γ(n+z))/Γ(n)n$^z$=1{\textstyle \lim _{n\to \infty }{\frac {\Gamma (n+z)}{\Gamma (n)\;n^{z}}}=1} for all complex numbers $z$.
In a certain sense, the log-gamma function is the more natural form; it makes some intrinsic attributes of the function clearer. A striking example is the Taylor series of logΓ around 1: $\operatorname {log\Gamma } (z+1)=-\gamma z+\sum _{k=2}^{\infty }{\frac {\zeta (k)}{k}}\,(-z)^{k}\qquad \forall \;|z|<1$ with ζ(k) denoting the Riemann zeta function at k.
So, using the following property: $\zeta (s)\Gamma (s)=\int _{0}^{\infty }{\frac {t^{s}}{e^{t}-1}}\,{\frac {dt}{t}}$ an integral representation for the log-gamma function is: $\operatorname {log\Gamma } (z+1)=-\gamma z+\int _{0}^{\infty }{\frac {e^{-zt}-1+zt}{t\left(e^{t}-1\right)}}\,dt$ or, setting z = 1 to obtain an integral for γ, we can replace the γ term with its integral and incorporate that into the above formula, to get: $\operatorname {log\Gamma } (z+1)=\int _{0}^{\infty }{\frac {e^{-zt}-ze^{-t}-1+z}{t\left(e^{t}-1\right)}}\,dt\,.$
There also exist special formulas for the logarithm of the gamma function for rational z. For instance, if $k$ and $n$ are integers with $k<n$ and $k\neq n/2\,,$ then ${\begin{aligned}\operatorname {log\Gamma } \left({\frac {k}{n}}\right)=&{\frac {\,(n-2k)\log 2\pi \,}{2n}}+{\frac {1}{2}}\left\{\,\log \pi -\log \sin {\frac {\pi k}{n}}\,\right\}+{\frac {1}{\pi }}\!\sum _{r=1}^{n-1}{\frac {\,\gamma +\log r\,}{r}}\cdot \sin {\frac {\,2\pi rk\,}{n}}\\&-{\frac {1}{2\pi }}\sin {\frac {2\pi k}{n}}\cdot \!\int _{0}^{\infty }\!\!{\frac {\,e^{-nx}\!\cdot \log x\,}{\,\cosh x-\cos(2\pi k/n)\,}}\,{\mathrm {d} }x.\end{aligned}}$This formula is sometimes used for numerical computation, since the integrand decreases very quickly.

### Integration over log-gamma

The integral $\int _{0}^{z}\operatorname {log\Gamma } (x)\,dx$ can be expressed in terms of the Barnes G-function (see Barnes G-function for a proof): $\int _{0}^{z}\operatorname {log\Gamma } (x)\,dx={\frac {z}{2}}\log(2\pi )+{\frac {z(1-z)}{2}}+z\operatorname {log\Gamma } (z)-\log G(z+1)$ where Re(z) > −1.
It can also be written in terms of the Hurwitz zeta function: $\int _{0}^{z}\operatorname {log\Gamma } (x)\,dx={\frac {z}{2}}\log(2\pi )+{\frac {z(1-z)}{2}}-\zeta '(-1)+\zeta '(-1,z).$
When $z=1$ it follows that $\int _{0}^{1}\operatorname {log\Gamma } (x)\,dx={\frac {1}{2}}\log(2\pi ),$ and this is a consequence of Raabe's formula as well. O. Espinosa and V. Moll derived a similar formula for the integral of the square of $\operatorname {log\Gamma }$: $\int _{0}^{1}\log ^{2}\Gamma (x)dx={\frac {\gamma ^{2}}{12}}+{\frac {\pi ^{2}}{48}}+{\frac {1}{3}}\gamma L_{1}+{\frac {4}{3}}L_{1}^{2}-\left(\gamma +2L_{1}\right){\frac {\zeta ^{\prime }(2)}{\pi ^{2}}}+{\frac {\zeta ^{\prime \prime }(2)}{2\pi ^{2}}},$ where $L_{1}$ is ${\frac {1}{2}}\log(2\pi )$.
D. H. Bailey and his co-authors gave an evaluation for $L_{n}:=\int _{0}^{1}\log ^{n}\Gamma (x)\,dx$ when $n=1,2$ in terms of the Tornheim–Witten zeta function and its derivatives.
In addition, it is also known that $\lim _{n\to \infty }{\frac {L_{n}}{n!}}=1.$

## Approximations

Complex values of the gamma function can be approximated using Stirling's approximation or the Lanczos approximation, $\Gamma (z)\sim {\sqrt {2\pi }}z^{z-1/2}e^{-z}\quad {\hbox{as }}z\to \infty {\hbox{ in }}\left|\arg(z)\right|<\pi .$ This is precise in the sense that the ratio of the approximation to the true value approaches 1 in the limit as |z| goes to infinity.
The gamma function can be computed to fixed precision for $\operatorname {Re} (z)\in [1,2]$ by applying integration by parts to Euler's integral. For any positive number x the gamma function can be written ${\begin{aligned}\Gamma (z)&=\int _{0}^{x}e^{-t}t^{z}\,{\frac {dt}{t}}+\int _{x}^{\infty }e^{-t}t^{z}\,{\frac {dt}{t}}\\&=x^{z}e^{-x}\sum _{n=0}^{\infty }{\frac {x^{n}}{z(z+1)\cdots (z+n)}}+\int _{x}^{\infty }e^{-t}t^{z}\,{\frac {dt}{t}}.\end{aligned}}$
When Re(z) ∈ [1,2] and $x\geq 1$, the absolute value of the last integral is smaller than $(x+1)e^{-x}$. By choosing a large enough $x$, this last expression can be made smaller than $2^{-N}$ for any desired value $N$. Thus, the gamma function can be evaluated to $N$ bits of precision with the above series.
A fast algorithm for calculation of the Euler gamma function for any algebraic argument (including rational) was constructed by E.A. Karatsuba.
For arguments that are integer multiples of ⁠1/24⁠, the gamma function can also be evaluated quickly using arithmetic–geometric mean iterations (see particular values of the gamma function).

## Practical implementations

Unlike many other functions, such as a Normal Distribution, no obvious fast, accurate implementation that is easy to implement for the Gamma Function $\Gamma (z)$ is easily found. Therefore, it is worth investigating potential solutions. For the case that speed is more important than accuracy, published tables for $\Gamma (z)$ are easily found in an Internet search, such as the Online Wiley Library. Such tables may be used with linear interpolation. Greater accuracy is obtainable with the use of cubic interpolation at the cost of more computational overhead. Since $\Gamma (z)$ tables are usually published for argument values between 1 and 2, the property $\Gamma (z+1)=z\ \Gamma (z)$ may be used to quickly and easily translate all real values $z<1$ and $z>2$ into the range $1\leq z\leq 2$, such that only tabulated values of $z$ between 1 and 2 need be used.
If interpolation tables are not desirable, then the Lanczos approximation mentioned above works well for 1 to 2 digits of accuracy for small, commonly used values of z. If the Lanczos approximation is not sufficiently accurate, the Stirling's formula for the Gamma Function may be used.

## Applications

One author describes the gamma function as "Arguably, the most common special function, or the least 'special' of them. The other transcendental functions […] are called 'special' because you could conceivably avoid some of them by staying away from many specialized mathematical topics. On the other hand, the gamma function Γ(z) is most difficult to avoid."

### Integration problems

The gamma function finds application in such diverse areas as quantum physics, astrophysics and fluid dynamics. The gamma distribution, which is formulated in terms of the gamma function, is used in statistics to model a wide range of processes; for example, the time between occurrences of earthquakes.
The primary reason for the gamma function's usefulness in such contexts is the prevalence of expressions of the type $f(t)e^{-g(t)}$ which describe processes that decay exponentially in time or space. Integrals of such expressions can occasionally be solved in terms of the gamma function when no elementary solution exists. For example, if f is a power function and g is a linear function, a simple change of variables $u:=a\cdot t$ gives the evaluation
$\int _{0}^{\infty }t^{b}e^{-at}\,dt={\frac {1}{a^{b}}}\int _{0}^{\infty }u^{b}e^{-u}d\left({\frac {u}{a}}\right)={\frac {\Gamma (b+1)}{a^{b+1}}}.$
The fact that the integration is performed along the entire positive real line might signify that the gamma function describes the cumulation of a time-dependent process that continues indefinitely, or the value might be the total of a distribution in an infinite space.
It is of course frequently useful to take limits of integration other than 0 and ∞ to describe the cumulation of a finite process, in which case the ordinary gamma function is no longer a solution; the solution is then called an incomplete gamma function. (The ordinary gamma function, obtained by integrating across the entire positive real line, is sometimes called the complete gamma function for contrast.)
An important category of exponentially decaying functions is that of Gaussian functions $ae^{-{\frac {(x-b)^{2}}{c^{2}}}}$ and integrals thereof, such as the error function. There are many interrelations between these functions and the gamma function; notably, the factor ${\sqrt {\pi }}$ obtained by evaluating Γ(1/2){\textstyle \Gamma \left({\frac {1}{2}}\right)} is the "same" as that found in the normalizing factor of the error function and the normal distribution.
The integrals discussed so far involve transcendental functions, but the gamma function also arises from integrals of purely algebraic functions. In particular, the arc lengths of ellipses and of the lemniscate, which are curves defined by algebraic equations, are given by elliptic integrals that in special cases can be evaluated in terms of the gamma function. The gamma function can also be used to calculate "volume" and "area" of n-dimensional hyperspheres.

### Calculating products

The gamma function's ability to generalize factorial products immediately leads to applications in many areas of mathematics; in combinatorics, and by extension in areas such as probability theory and the calculation of power series. Many expressions involving products of successive integers can be written as some combination of factorials, the most important example perhaps being that of the binomial coefficient. For example, for any complex numbers z and n, with |z| < 1, we can write $(1+z)^{n}=\sum _{k=0}^{\infty }{\frac {\Gamma (n+1)}{k!\Gamma (n-k+1)}}z^{k},$ which closely resembles the binomial coefficient when n is a non-negative integer, $(1+z)^{n}=\sum _{k=0}^{n}{\frac {n!}{k!(n-k)!}}z^{k}=\sum _{k=0}^{n}{\binom {n}{k}}z^{k}.$
The example of binomial coefficients motivates why the properties of the gamma function when extended to negative numbers are natural. A binomial coefficient gives the number of ways to choose k elements from a set of n elements; if k > n, there are of course no ways. If k > n, (n − k)! is the factorial of a negative integer and hence infinite if we use the gamma function definition of factorials—dividing by infinity gives the expected value of 0.
We can replace the factorial by a gamma function to extend any such formula to the complex numbers. Generally, this works for any product wherein each factor is a rational function of the index variable, by factoring the rational function into linear expressions. If P and Q are monic polynomials of degree m and n with respective roots p$_1$, …, p$_m$ and q$_1$, …, q$_n$, we have $\prod _{i=a}^{b}{\frac {P(i)}{Q(i)}}=\left(\prod _{j=1}^{m}{\frac {\Gamma (b-p_{j}+1)}{\Gamma (a-p_{j})}}\right)\left(\prod _{k=1}^{n}{\frac {\Gamma (a-q_{k})}{\Gamma (b-q_{k}+1)}}\right).$
If we have a way to calculate the gamma function numerically, it is very simple to calculate numerical values of such products. The number of gamma functions in the right-hand side depends only on the degree of the polynomials, so it does not matter whether b − a equals 5 or 10$^5$. By taking the appropriate limits, the equation can also be made to hold even when the left-hand product contains zeros or poles.
By taking limits, certain rational products with infinitely many factors can be evaluated in terms of the gamma function as well. Due to the Weierstrass factorization theorem, analytic functions can be written as infinite products, and these can sometimes be represented as finite products or quotients of the gamma function. We have already seen one striking example: the reflection formula essentially represents the sine function as the product of two gamma functions. Starting from this formula, the exponential function as well as all the trigonometric and hyperbolic functions can be expressed in terms of the gamma function.
More functions yet, including the hypergeometric function and special cases thereof, can be represented by means of complex contour integrals of products and quotients of the gamma function, called Mellin–Barnes integrals.

### Analytic number theory

An application of the gamma function is the study of the Riemann zeta function. A fundamental property of the Riemann zeta function is its functional equation: $\Gamma \left({\frac {s}{2}}\right)\zeta (s)\pi ^{-{\frac {s}{2}}}=\Gamma \left({\frac {1-s}{2}}\right)\zeta (1-s)\pi ^{-{\frac {1-s}{2}}}.$
Among other things, this provides an explicit form for the analytic continuation of the zeta function to a meromorphic function in the complex plane and leads to an immediate proof that the zeta function has infinitely many so-called "trivial" zeros on the real line. Borwein et al. call this formula "one of the most beautiful findings in mathematics". Another contender for that title might be $\zeta (s)\;\Gamma (s)=\int _{0}^{\infty }{\frac {t^{s}}{e^{t}-1}}\,{\frac {dt}{t}}.$
Both formulas were derived by Bernhard Riemann in his seminal 1859 paper "Ueber die Anzahl der Primzahlen unter einer gegebenen Größe" ("On the Number of Primes Less Than a Given Magnitude"), one of the milestones in the development of analytic number theory—the branch of mathematics that studies prime numbers using the tools of mathematical analysis.

## History

The gamma function has caught the interest of some of the most prominent mathematicians of all time. Its history, notably documented by Philip J. Davis in an article that won him the 1963 Chauvenet Prize, reflects many of the major developments within mathematics since the 18th century. In the words of Davis, "each generation has found something of interest to say about the gamma function. Perhaps the next generation will also."

### 18th century: Euler and Stirling

The problem of extending the factorial to non-integer arguments was apparently first considered by Daniel Bernoulli and Christian Goldbach in the 1720s. In particular, in a letter from Bernoulli to Goldbach dated 6 October 1729 Bernoulli introduced the product representation $x!=\lim _{n\to \infty }\left(n+1+{\frac {x}{2}}\right)^{x-1}\prod _{k=1}^{n}{\frac {k+1}{k+x}}$ which is well defined for real values of x other than the negative integers.
Leonhard Euler later gave two different definitions: the first was not his integral but an infinite product that is well defined for all complex numbers n other than the negative integers, $n!=\prod _{k=1}^{\infty }{\frac {\left(1+{\frac {1}{k}}\right)^{n}}{1+{\frac {n}{k}}}}\,,$ of which he informed Goldbach in a letter dated 13 October 1729. He wrote to Goldbach again on 8 January 1730, to announce his discovery of the integral representation $n!=\int _{0}^{1}(-\log s)^{n}\,ds\,,$ which is valid when the real part of the complex number n is strictly greater than −1 (i.e., $\Re (n)>-1$). By the change of variables t = −ln s, this becomes the familiar Euler integral. Euler published his results in the paper "De progressionibus transcendentibus seu quarum termini generales algebraice dari nequeunt" ("On transcendental progressions, that is, those whose general terms cannot be given algebraically"), submitted to the St. Petersburg Academy on 28 November 1729. Euler further discovered some of the gamma function's important functional properties, including the reflection formula.
James Stirling, a contemporary of Euler, also attempted to find a continuous expression for the factorial and came up with what is now known as Stirling's formula. Although Stirling's formula gives a good estimate of n!, also for non-integers, it does not provide the exact value. Extensions of his formula that correct the error were given by Stirling himself and by Jacques Philippe Marie Binet.

### 19th century: Gauss, Weierstrass and Legendre

Carl Friedrich Gauss rewrote Euler's product as $\Gamma (z)=\lim _{m\to \infty }{\frac {m^{z}m!}{z(z+1)(z+2)\cdots (z+m)}}$ and used this formula to discover new properties of the gamma function. Although Euler was a pioneer in the theory of complex variables, he does not appear to have considered the factorial of a complex number, as instead Gauss first did. Gauss also proved the multiplication theorem of the gamma function and investigated the connection between the gamma function and elliptic integrals.
Karl Weierstrass further established the role of the gamma function in complex analysis, starting from yet another product representation, $\Gamma (z)={\frac {e^{-\gamma z}}{z}}\prod _{k=1}^{\infty }\left(1+{\frac {z}{k}}\right)^{-1}e^{\frac {z}{k}},$ where γ is the Euler–Mascheroni constant. Weierstrass originally wrote his product as one for ⁠1/Γ⁠, in which case it is taken over the function's zeros rather than its poles. Inspired by this result, he proved what is known as the Weierstrass factorization theorem—that any entire function can be written as a product over its zeros in the complex plane; a generalization of the fundamental theorem of algebra.
The name gamma function and the symbol Γ were introduced by Adrien-Marie Legendre around 1811; Legendre also rewrote Euler's integral definition in its modern form. Although the symbol is an upper-case Greek gamma, there is no accepted standard for whether the function name should be written "gamma function" or "Gamma function" (some authors simply write "Γ-function"). The alternative "pi function" notation Π(z) = z! due to Gauss is sometimes encountered in older literature, but Legendre's notation is dominant in modern works.
It is justified to ask why we distinguish between the "ordinary factorial" and the gamma function by using distinct symbols, and particularly why the gamma function should be normalized to Γ(n + 1) = n! instead of simply using "Γ(n) = n!". Consider that the notation for exponents, x$^n$, has been generalized from integers to complex numbers x$^z$ without any change. Legendre's motivation for the normalization is not known, and has been criticized as cumbersome by some (the 20th-century mathematician Cornelius Lanczos, for example, called it "void of any rationality" and would instead use z!). Legendre's normalization does simplify some formulae, but complicates others. From a modern point of view, the Legendre normalization of the gamma function is the integral of the additive character e$^{−x}$ against the multiplicative character x$^z$ with respect to the Haar measure dx/x {\textstyle {\frac {dx}{x}}} on the Lie group R$^+$. Thus this normalization makes it clearer that the gamma function is a continuous analogue of a Gauss sum.

### 19th–20th centuries: characterizing the gamma function

It is somewhat problematic that a large number of definitions have been given for the gamma function. Although they describe the same function, it is not entirely straightforward to prove the equivalence. Stirling never proved that his extended formula corresponds exactly to Euler's gamma function; a proof was first given by Charles Hermite in 1900. Instead of finding a specialized proof for each formula, it would be desirable to have a general method of identifying the gamma function.
One way to prove equivalence would be to find a differential equation that characterizes the gamma function. Most special functions in applied mathematics arise as solutions to differential equations, whose solutions are unique. However, the gamma function does not appear to satisfy any simple differential equation. Otto Hölder proved in 1887 that the gamma function at least does not satisfy any algebraic differential equation by showing that a solution to such an equation could not satisfy the gamma function's recurrence formula, making it a transcendentally transcendental function. This result is known as Hölder's theorem.
A definite and generally applicable characterization of the gamma function was not given until 1922. Harald Bohr and Johannes Mollerup then proved what is known as the Bohr–Mollerup theorem: that the gamma function is the unique solution to the factorial recurrence relation that is positive and logarithmically convex for positive z and whose value at 1 is 1 (a function is logarithmically convex if its logarithm is convex). Another characterisation is given by the Wielandt theorem.
The Bohr–Mollerup theorem is useful because it is relatively easy to prove logarithmic convexity for any of the different formulas used to define the gamma function. Taking things further, instead of defining the gamma function by any particular formula, we can choose the conditions of the Bohr–Mollerup theorem as the definition, and then pick any formula we like that satisfies the conditions as a starting point for studying the gamma function. This approach was used by the Bourbaki group.
Borwein & Corless review three centuries of work on the gamma function.

### Reference tables and software

Although the gamma function can be calculated virtually as easily as any mathematically simpler function with a modern computer—even with a programmable pocket calculator—this was of course not always the case. Until the mid-20th century, mathematicians relied on hand-made tables; in the case of the gamma function, notably a table computed by Gauss in 1813 and one computed by Legendre in 1825.
Tables of complex values of the gamma function, as well as hand-drawn graphs, were given in Tables of Functions With Formulas and Curves by Jahnke and Emde [de], first published in Germany in 1909. According to Michael Berry, "the publication in J&E of a three-dimensional graph showing the poles of the gamma function in the complex plane acquired an almost iconic status."
There was in fact little practical need for anything but real values of the gamma function until the 1930s, when applications for the complex gamma function were discovered in theoretical physics. As electronic computers became available for the production of tables in the 1950s, several extensive tables for the complex gamma function were published to meet the demand, including a table accurate to 12 decimal places from the U.S. National Bureau of Standards.
Double-precision floating-point implementations of the gamma function and its logarithm are now available in most scientific computing software and special functions libraries, for example TK Solver, Matlab, GNU Octave, and the GNU Scientific Library. The gamma function was also added to the C standard library (math.h). Arbitrary-precision implementations are available in most computer algebra systems, such as Mathematica and Maple. PARI/GP, MPFR and MPFUN contain free arbitrary-precision implementations. In some software calculators, e.g. Windows Calculator and GNOME Calculator, the factorial function returns Γ(x + 1) when the input x is a non-integer value.