## Factorial Let us start with factorial function. Informally, it is defined as a product of all natural numbers from $$ 1 $$ to $$ n $$ inclusively: $$ n! = 1 \cdot 2 \cdot 3 \cdot ... \cdot n = \prod_{k=1}^n k $$ The formal definition is given recursively: 1. $$ 1! = 1 $$ 2. $$ (n+1)! = (n+1) \cdot n!, n=1,2,3... $$ We can also define factorial at 0 keeping the recursive formula: $$ 1! = 1 \cdot 0! $$ $$ 0! = \frac{1!}{1} = 1 $$ ## Definition of gamma function What is about factorial at negative, fractional or complex numbers? This is where gamma function comes from. First of all we consider an integral that corresponds to the same recursive formula: $$ \Gamma(x) = \int_0^\infty t^{x-1} e^{-t} dt $$ It converges for all real $$ x > 0 $$. Now we calculate its value at $$ x = 1 $$: $$ \Gamma(1) = \int_0^\infty e^{-t} dt = 1 $$ Also we can obtain the recursive formula for natural $$ n $$: $$ \Gamma(n+1) = \int_0^\infty t^n e^{-t} dt = (- t^n e^{-t}) \Big|_{t=0}^{t=\infty} + \int_0^\infty (t^n)' e^{-t} dt $$ Since $$ n \geq 1 $$ and the exponent goes to zero faster than the power growing, the first term equals to zero: $$ \Gamma(n+1) = n \int_0^\infty t^{n-1} e^{-t} dt $$ $$ \Gamma(n+1) = n \Gamma(n) $$ This looks similar to factorial if we add an offset $$ 1 $$. Thus we have: $$ \Gamma(n+1) = n! $$ We may question: is gamma function an only generalization of factorial that satisfies the value at $$ 1 $$ and the recursion? The answer is no, because we obviously can consider the function $$ F_c $$: $$ F_c(x) = \Gamma(x) \cdot \cos (2 \pi x) $$ $$ F_c(1) = 1 $$ $$ F_c(n+1) = n F_c(n), n=1,2,3... $$ So, since there are many suitable functions, denote them as $$ F(x) $$ and represent them as a product of gamma function and a multiplier $$ G(x) $$: $$ F(x) = \Gamma(x) \cdot G(x) $$ Now we are searching for conditions for $$ G(x) $$. First of all, we have $$ F(1) = \Gamma(1) = 1 $$, so $$ G(1) = 1 $$. Also we have the recursion for $$ F $$ and $$ \Gamma $$ for all $$ x > 0 $$: $$ F(x+1) = \Gamma(x+1) G(x+1) $$ $$ x F(x) = x \Gamma(x) G(x+1) $$ $$ x \Gamma(x) G(x) = x \Gamma(x) G(x+1) $$ $$ G(x) = G(x+1) $$ In other words, $$ G(x) $$ is an arbitrary periodic function having the period $$ 1 $$ and the value $$ 1 $$ at all integer arguments. ## Stirling formula Stirling formula helps to calculate factorial at big arguments. To get this formula, first, we consider a logarithm of factorial because it may be represented as a sum: $$ \ln n! = \ln 1 + \ln 2 + \ln 3 + ... + \ln n = \sum_{k=1}^n \ln k $$ Now the idea is to transform this sum into an integral using $$ n \to \infty $$: $$ \ln n! = \sum_{k=1}^n \ln k = \sum_{k=1}^n (\ln k - \ln n) + n \ln n = $$ $$ = \sum_{k=1}^n \ln \frac{k}{n} + n \ln n = n \sum_{k=1}^n \ln \frac{k}{n} \cdot \frac{1}{n} + n \ln n = $$ $$ = n \left( \int_0^1 \ln x dx + o(1) \right) + n \ln n = $$ $$ = n \ln n - n + o(n) $$ Finally: $$ \ln n! = n \ln n - n + o(n) $$ $$ n! = \left( \frac{n}{e} \right)^n \cdot e^{o(n)} $$ Same formula works for gamma function as well for $$ x \to \infty $$: $$ \ln \Gamma(x) = x \ln x - x + o(x) $$ ## Convex factorial generalization Above we got the result that factorial can be generalized as a product $$ F(x) = \Gamma(x) \cdot G(x) $$, where $$ G(x) $$ is an arbitrary periodic function having the value $$ 1 $$ and integer arguments. So for the logarithm of both parts: $$ \ln F(x) = \ln \Gamma(x) + \ln G(x) $$ $$ \ln G(x) $$ is also periodic. Considering $$ x \to \infty $$, we can conclude that if $$ \ln G(x) $$ varies, the total $$ \ln F(x) $$ is not convex, because $$ \ln \Gamma(x) $$ is convex and it gets closer and closer to the linear form so for any variance of $$ G(x) $$ there is a big $$ x $$ after which $$ \ln \Gamma(x) + \ln G(x) $$ is not convex. Therefore, if we require $$ F(x) $$ to be convex at $$ x \to \infty $$, gamma function will be the only option to generalize factorial. ## Values of gamma function at half-integer arguments First of all we should calculate $$ \Gamma(1/2) $$: $$ \Gamma(1/2) = \int_0^\infty t^{-1/2} e^{-t} dt $$ Replacing $$ t = x^2 $$: $$ \Gamma(1/2) = \int_0^\infty \frac{1}{x} e^{-x^2} 2 x dx = 2 \int_0^\infty e^{-x^2} dx = \int_{-\infty}^{+\infty} e^{-x^2} dx $$ We square this result and apply the transformation into polar coordinates so $$ dx dy = \rho d \rho d \phi $$, and $$ x^2 + y^2 = \rho^2 $$: $$ (\Gamma(1/2))^2 = \left( \int_{-\infty}^{+\infty} e^{-x^2} dx \right)^2 = $$ $$ = \int_{-\infty}^{+\infty} e^{-x^2} dx \cdot \int_{-\infty}^{+\infty} e^{-y^2} dy = $$ $$ = \int_{\mathbb{R}^2} dxdy e^{-(x^2 + y^2)} = \int_0^{2 \pi} d \phi \int_0^\infty \rho d \rho e^{-\rho^2} = 2 \pi \int_0^\infty \rho d \rho e^{-\rho^2} = $$ $$ = \pi \int_0^\infty d(\rho^2) e^{-\rho^2} = \pi $$ So finally we have: $$ \Gamma(1/2) = \sqrt{\pi} $$ The other values can be obtained via the recursive formula: $$ \Gamma(n+1/2) = \frac{(2n-1)!!}{2^n} \sqrt{\pi} = \frac{(2n)!}{2^{2n} n!} \sqrt{\pi} $$ Here double factorial means the product of odd numbers only $$ (2n-1)!! = 1 \cdot 3 \cdot 5 \cdot ... \cdot (2n-1) $$. ## Digamma function Digamma function $$ \psi(x) $$ is defined as a derivative of logarithm of gamma function: $$ \psi(x) = (\ln \Gamma(x))' = \frac{\Gamma'(x)}{\Gamma(x)} $$ We can calculate the recursive formula: $$ \psi(x+1) = (\ln \Gamma(x + 1))' = (\ln \Gamma(x) + \ln x)' = (\ln \Gamma(x))' + (\ln x)' $$ $$ \psi(x+1) = \psi(x) + \frac{1}{x} $$ For natural arguments $$ n $$ digamma function is a harmonic number with an offset $$ C $$: $$ \psi(n+1) = 1+\frac{1}{2}+\frac{1}{3}+...+\frac{1}{n} + C = \sum_{k=1}^n \frac{1}{k} + C $$ Considering $$ n \to \infty $$, we have a formula with Euler-Mascheroni constant $$ \gamma $$: $$ \sum_{k=1}^n \frac{1}{k} = \ln n + \gamma + o(1) $$ Thus for $$ x \to \infty $$ we have: $$ \psi(x) = \ln x + \gamma + C + o(1) $$ On the other hand, above we got Stirling formula for $$ x \to \infty $$, so we can take its derivative: $$ \ln \Gamma(x) = x \ln x - x + o(x) $$ $$ \psi(x) = (\ln \Gamma(x))' = (x \ln x - x + o(x))' = \ln x + o(1) $$ This makes us conclude, that $$ C = - \gamma $$. So the values of digamma function at natural arguments are: $$ \psi(n+1) = - \gamma + H_n $$ Where $$ H_n $$ is a harmonic number defined as: $$ H_n = \sum_{k=1}^n \frac{1}{k} $$ Particularly, we have a result for the integral: $$ \int_0^\infty \ln t \cdot e^{-t} dt = \psi(1) = - \gamma $$ ## Digamma function generalization We use an idea of geometric series: $$ \psi(n) = - \gamma + \sum_{k=1}^{n-1} \frac{1}{k} = - \gamma + \sum_{k=1}^{n-1} \int_0^1 t^{k-1} dt = $$ $$ = - \gamma + \int_0^1 \sum_{k=1}^{n-1} t^{k-1} dt = - \gamma + \int_0^1 \frac{1-t^{n-1}}{1-t} dt $$ So the generalization can be: $$ \psi(x) = - \gamma + \int_0^1 \frac{1-t^{x-1}}{1-t} dt $$ If $$ x \in \mathbb{Q} $$, the integral can be calculated and represented using $$ \arctan $$ and $$ \ln $$ functions because if $$ x = \frac{m}{n} $$ we can rewrite the integral for $$ s = t^n $$ and the inner function becomes a fraction of finite polynomials. Having $$ \frac{1}{1-t} = \sum_{k=0}^\infty t^k $$ the integral also can be represented as a series: $$ \psi(x+1) = - \gamma + \sum_{k=1}^\infty \left( \frac{1}{k} - \frac{1}{k+x} \right) = - \gamma + x \sum_{k=1}^\infty \frac{1}{k(k+x)} $$ Particularly, we just learnt how to calculate the following sum: $$ \sum_{k=1}^\infty \frac{1}{k(k+x)} = \frac{1}{x} \int_0^1 \frac{1-t^x}{1-t} dt $$ Actually, keeping the recursion the generalization can be any function $$ f(x) $$ that can be represented as $$ f(x) = \psi(x) + h(x) $$, where $$ h(x) $$ is an arbitrary periodic function with the period $$ 1 $$ and the values $$ 0 $$ at integer arguments. On the other hand, requiring the generalization $$ f(x) $$ to be convex at $$ x \to \infty $$, $$ h(x) $$ must be zero. Thus the expression we just got above is correct and totally satisfies digamma function to be the derivative of log gamma function at all real $$ x > 0 $$. ## Digamma at half-integer arguments Above we calculated gamma function at half-integer arguments. Is there similar result for digamma function? The answer is yes. First we calculate the value at $$ 1/2 $$: $$ \psi(1/2) = - \gamma + \int_0^1 \frac{1-t^{1/2-1}}{1-t} dt = $$ $$ = - \gamma - \int_0^1 \frac{1-\sqrt{t}}{\sqrt{t}(1-t)} dt = - \gamma - \int_0^1 \frac{1}{\sqrt{t}(1+\sqrt{t})} dt = $$ $$ = - \gamma - 2 \int_0^1 \frac{ds}{1+s} = - \gamma - 2 \ln 2 $$ The other values can be obtained recursively: $$ \psi(n + 1/2) = \psi(1/2) + \frac{2}{1} + \frac{2}{3} + \frac{2}{5} + ... + \frac{2}{2n-1} $$ $$ \psi(n + 1/2) = - \gamma - 2 \ln 2 + 2 H_{2n} - H_{n} $$ ## Negative arguments of gamma and digamma functions The corresponding integrals of gamma and digamma functions diverge. Nevertheless we still can keep the recursion going backward from the positive area by step $$ 1 $$: $$ \Gamma(x) = \frac{\Gamma(x+1)}{x} $$ $$ \psi(x) = \psi(x+1) - \frac{1}{x} $$ The problem comes with zero and negative integer $$ x $$ only due to division by zero. But the results are finite for the other negative $$ x $$ and we will consider the cases for half-integer arguments: $$ \Gamma(-n+1/2) = \frac{(-1)^n 2^n}{(2n-1)!!} \sqrt{\pi} = \frac{(-1)^n 2^{2n} n!}{(2n)!} \sqrt{\pi} $$ $$ \psi(-n+1/2) = \psi(n+1/2) = - \gamma - 2 \ln 2 + 2 H_{2n} - H_{n} $$ ## Relation to beta function Beta function is a function of two arguments and defined like this: $$ B(a, b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt $$ Let us consider a product of gamma functions at different arguments. Fortunately, the integrals can be simplified together: $$ \Gamma(a) \Gamma(b) = \int_0^\infty u^{a-1} e^{-u} du \int_0^\infty v^{b-1} e^{-v} dv = $$ $$ = \int_0^\infty du \int_u^\infty dw \cdot u^{a-1} (w-u)^{b-1} e^{-w} = $$ $$ = \int_0^\infty dw \int_0^s du \cdot w^{a+b-2} \cdot \left(\frac{u}{w}\right)^{a-1} \left(1-\frac{u}{w}\right)^{b-1} e^{-w} = $$ $$ = \int_0^\infty w^{a+b-1} e^{-w} dw \cdot \int_0^1 t^{a-1} (1-t)^{b-1} dt = $$ $$ = \Gamma(a+b) B(a, b) $$ Or it can be rewritten: $$ B(a,b) = \frac{\Gamma(a) \Gamma(b)}{\Gamma(a+b)} $$ Also there is another representation of beta function that can be done after the replacement $$ s = \frac{t}{1-t} $$, so $$ t = \frac{s}{1+s} $$ and $$ dt = \frac{ds}{(1+s)^2} $$: $$ B(a, b) = \int_0^1 t^{a-1} (1-t)^{b-1} dt = $$ $$ = \int_0^\infty \left( \frac{s}{1+s} \right)^{a-1} \cdot \left( \frac{1}{1+s} \right)^{b-1} \cdot \frac{ds}{(1+s)^2} = $$ $$ = \int_0^\infty \frac{s^{a-1}}{(1+s)^{a+b}} ds $$ Finally: $$ B(a,b) = \int_0^\infty \frac{s^{a-1}}{(1+s)^{a+b}} ds $$ ## Reflection formulas We may notice that the values of gamma function at $$ (n+1/2) $$ and at $$ (-n+1/2) $$ look similar. Their product does not depend on $$ n $$ (neglecting the sign) and equals to $$ \pi $$. So maybe there is a symmetry with respect to $$ 1/2 $$, so we can check a product of the values at $$ x $$ and $$ (1-x) $$: $$ \Gamma(x) \Gamma(1-x) = B(x, 1-x) \Gamma(1) = \int_0^\infty \frac{s^{x-1}}{1+s} ds = $$ $$ = \int_0^1 \frac{s^{x-1}}{1+s} ds + \int_1^\infty \frac{s^{x-1}}{1+s} ds = $$ $$ = \int_0^1 \frac{s^{x-1}}{1+s} ds + \int_0^1 \frac{s^{-x}}{1+s} ds = $$ $$ = \int_0^1 s^{x-1} (1-s+s^2-s^3+...) ds + \int_0^1 s^{-x} (1-s+s^2-s^3+...) ds = $$ $$ = \left( \frac{1}{x} - \frac{1}{x+1} + \frac{1}{x+2} - ... \right) + \left( - \frac{1}{x-1} + \frac{1}{x-2} - \frac{1}{x-3} + ... \right) = $$ $$ = \sum_{k=-\infty}^{+\infty} \frac{(-1)^k}{x+k} = \frac{\pi}{\sin (\pi x)} $$ The last infinite sum can be obtained applying Fourier transformation to the function $$ \cos (\alpha x), x \in [-\pi, \pi] $$. But here we are using it as a well-known result without a proof. Finally, we have the reflection formula for gamma function: $$ \Gamma(x) \Gamma(1-x) = \frac{\pi}{\sin (\pi x)} $$ Applying logarithm and derivative for both parts we can build a reflection formula to digamma function: $$ (\ln \Gamma(x) + \ln \Gamma(1-x))' = \left( \ln \left( \frac{\pi}{\sin (\pi x)} \right) \right)' $$ $$ \psi(x) - \psi(1-x) = - \pi \cot (\pi x) $$ In the end, we get the following reflection formula: $$ \psi(1-x) - \psi(x) = \pi \cot (\pi x) $$ ## Gamma function as an infinite product We may notice, that digamma function has a convenient formula to integrate, so this may give us an expression for log gamma. $$ \psi(x+1) = - \gamma + \sum_{k=1}^\infty \left( \frac{1}{k} - \frac{1}{k+x} \right) $$ $$ \int \psi(x+1) dx = \int \left( - \gamma + \sum_{k=1}^\infty \left( \frac{1}{k} - \frac{1}{k+x} \right) \right) dx = $$ $$ = \int \left( - \gamma + \sum_{k=1}^\infty \left( \frac{1}{k} - \frac{1/k}{1+x/k} \right) \right) dx = $$ $$ = - \gamma x + \sum_{k=1}^\infty \left( \frac{x}{k} - \ln (1 + x/k) \right) + C $$ We had to transform $$ \frac{1}{k+x} $$ to $$ \frac{1/k}{1 + x/k} $$, otherwise we would get $$ \ln(k+x) $$ that diverges in the sum. If we want the final integral to be log gamma function, we need to calculate the constant $$ C $$. Since log gamma at $$ 1 $$ is zero, this integral at $$ x=0 $$ must be zero, thus $$ C=0 $$. $$ \ln \Gamma(x+1) = - \gamma x + \sum_{k=1}^\infty \left( \frac{x}{k} - \ln (1 + x/k) \right) $$ Or as a product: $$ \Gamma(x+1) = e^{- \gamma x} \prod_{k=1}^\infty \frac{e^{x/k}}{1+x/k} $$ We can modify this formula, using the idea that $$ \sum_{k=1}^N \frac{1}{k} - \gamma \to \ln N $$ so $$ e^{-\gamma} \prod_{k=1}^N e^{1/k} \to N $$. On the other hand, $$ N + 1 = \frac{2}{1} \cdot \frac{3}{2} \cdot \frac{4}{3} \cdot ... \cdot \frac{N+1}{N} = \prod_{k=1}^N (1+1/k) \to N $$. Consequently, we get another expression for gamma function: $$ \Gamma(x+1) = \prod_{k=1}^\infty \frac{(1+1/k)^x}{1+x/k} $$ ## Gamma and digamma functions at complex arguments Above, for digamma function we got the following result: $$ \psi(x+1) = - \gamma + x \sum_{k=1}^\infty \frac{1}{k(k+x)} $$ If $$ x $$ is not a negative integer, the sum converges always even if $$ x $$ is complex. So this form can be considered as a complex continuation. $$ \psi(z+1) = - \gamma + z \sum_{k=1}^\infty \frac{1}{k(k+z)}, z \in \mathbb{C} $$ As for gamma function, its integral converges for $$ \Re(z) \in [1,2] $$: $$ \Gamma(z) = \int_0^\infty t^{z-1} e^{-t} dt, \Re(z) \in [1,2] $$ If so, the other values on the complex plane can be calculated recursively. The only exception is the points where we have division by zero in the recursion, that corresponds to zero and negative integer arguments - here gamma function has poles. What is about zeros of gamma function (zeros are $$ z $$ such that $$ \Gamma(z) = 0 $$)? We can consider the reflection formula: $$ \Gamma(z) \Gamma(1-z) = \frac{\pi}{\sin (\pi z)} $$ If gamma function has a zero at some $$ z $$, it must have a corresponding pole at $$ (1-z) $$ (let us note that $$ z $$ and $$ (1-z) $$ are always different points excepting the case $$ z=1/2 $$, but we already considered it before having the result $$ \Gamma(1/2) = \sqrt{\pi} \neq 0 $$, so $$ z=1/2 $$ is not a zero), because the right part of the reflection formula is never zero. But we already know all the poles that are zero and negative integers, that have corresponding reflected arguments at positive integers where gamma function obviously is never zero. We may conclude that gamma function has no zeros. This leads that $$ \frac{1}{\Gamma(z)} $$ is defined everywhere, has no poles and has zeros at zero and negative integer arguments.