TITLE: How to find the factorial of a fraction?
QUESTION [58 upvotes]: From what I know, the factorial function is defined as follows:
$$n! = n(n-1)(n-2) \cdots(3)(2)(1)$$
And $0! = 1$. However, this page seems to be saying that you can take the factorial of a fraction, like, for instance, $\frac{1}{2}!$, which they claim is equal to $\frac{1}{2}\sqrt\pi$ due to something called the gamma function. Moreover, they start getting the factorial of negative numbers, like $-\frac{1}{2}! = \sqrt{\pi}$
How is this possible? What is the definition of the factorial of a fraction? What about negative numbers?
I tried researching it on Wikipedia and such, but there doesn't seem to be a clear-cut answer.

REPLY [2 votes]: I derived a form of the gamma function (see here) using some calculus and neat little tricks.

Anyways, define the factorial with two conditions:

$n!=n(n-1)!$
$1!=1$

From this, you can get the factorial for any integer value, but it does nothing to show you fractional values, at least not yet.
Define a function $f(x):=\ln(x!)$ and manipulate as follows:
$$f(x)=\ln(x!)=\ln(x(x-1)!)=\ln((x-1)!)+\ln(x)=f(x-1)+\ln(x)$$
$$f(x)=f(x-1)+\ln(x)\tag1$$
Differentiate both sides (since the equation holds true for all $x$)
$$f'(x)=f'(x-1)+\frac1x\tag2$$
If you put $x-1$ into $(2)$, we get $f'(x-1)=f'(x-2)+\frac1{x-1}$, and repeat this process over and over...
$$f'(x)=f'(x-2)+\frac1{x-1}+\frac1x$$
$$f'(x)=f'(x-3)+\frac1{x-2}+\frac1{x-1}+\frac1x\\\vdots\\f'(x)=f'(0)+\frac11+\frac12+\dots+\frac1{x-1}+\frac1x\tag3$$
Note that $(3)$ only holds true for integer $x$, just like the factorial, but it is much easier to generalize.
Recall the geometric sum:
$$\frac{1-r^n}{1-r}=1+r+r^2+\dots+r^{n-1}$$
Integrate both sides with respect to $r$ from $0$ to $1$,
$$\begin{align}
\int_0^1\frac{1-r^n}{1-r}dr & =\int_0^11+r+r^2+\dots+r^{n-1}dr\\
& =\left.\frac11r+\frac12r^2+\frac13r^3+\dots+\frac1nr^n\right|_0^1\\
& =\frac11+\frac12+\dots+\frac1{x-1}+\frac1x\tag4\\
\end{align}$$
This is exactly what we need to extend $(3)$ to arbitrary $x$:
$$f'(x)=f'(0)+\int_0^1\frac{1-r^x}{1-r}dr\tag{3.1}$$
We then integrate this and apply the FTOC:
$$f(x)-\require{cancel}\cancelto0{f(0)}=\int_0^x\left(f'(0)+\int_0^1\frac{1-r^\phi}{1-r}dr\right)d\phi$$
$$f(x)=f'(0)x+\int_0^x\int_0^1\frac{1-r^\phi}{1-r}dr\ d\phi$$
Recall what $f(x)$ was:
$$\ln(x!)=f'(0)x+\int_0^x\int_0^1\frac{1-r^\phi}{1-r}dr\ d\phi$$
Use the second condition of the factorial and $x=1$
$$\ln(1!)=f'(0)+\int_0^1\int_0^1\frac{1-r^\phi}{1-r}dr\ d\phi$$
$$f'(0)=-\int_0^1\int_0^1\frac{1-r^\phi}{1-r}dr\ d\phi\tag5$$
So then,
$$x!=\exp\left[-x\int_0^1\int_0^1\frac{1-r^\phi}{1-r}dr\ d\phi+\int_0^x\int_0^1\frac{1-r^\phi}{1-r}dr\ d\phi\right]$$
which is equivalent to the gamma function.