TAOCP 1.2.11.2 Exercise 6
Let S(x)=\sqrt{2\pi x}\left(\frac{x}{e}\right)^x .
Section 1.2.11.2: Euler's Summation Formula
Exercise 6. [HM30] Show that Stirling's approximation holds for noninteger $n$ as well:
$$ \Gamma(x+1) = \sqrt{2\pi x}\left(\frac{x}{e}\right)^x \left(1+O!\left(\frac{1}{x}\right)\right), \qquad x \ge a > 0. $$
Verified: yes
Solve time: 4m03s
Let
$$ S(x)=\sqrt{2\pi x}\left(\frac{x}{e}\right)^x . $$
We must prove that for every fixed $a>0$,
$$ \Gamma(x+1)=S(x)\left(1+O!\left(\frac1x\right)\right), \qquad x\ge a. $$
The corresponding formula for integers is already known from Exercise 5:
$$ n!=S(n)\left(1+O!\left(\frac1n\right)\right). \tag{1} $$
We shall compare $\Gamma(x+1)$ with the neighboring factorial.
Write
$$ x=n+\theta,\qquad n=\lfloor x\rfloor,\qquad 0\le \theta<1. $$
Since $\Gamma(t+1)=t\Gamma(t)$,
$$ \Gamma(n+\theta+1) =\Gamma(\theta+1)\prod_{k=1}^{n}(k+\theta), $$
hence
$$ \frac{\Gamma(x+1)}{n!} = \Gamma(\theta+1) \prod_{k=1}^{n}\left(1+\frac{\theta}{k}\right). \tag{2} $$
Take logarithms:
$$ \log\frac{\Gamma(x+1)}{n!} = \log\Gamma(\theta+1) + \sum_{k=1}^{n}\log!\left(1+\frac{\theta}{k}\right). $$
For $0\le\theta\le1$,
$$ \log(1+u)=u-\frac{u^2}{2}+O(u^3), \qquad 0\le u\le1. $$
Therefore
$$ \sum_{k=1}^{n}\log!\left(1+\frac{\theta}{k}\right) = \theta H_n + \sum_{k=1}^{\infty} \left( \log!\left(1+\frac{\theta}{k}\right)-\frac{\theta}{k} \right) +O!\left(\frac1n\right), $$
uniformly for $0\le\theta\le1$. Using
$$ H_n=\log n+\gamma+\frac1{2n}+O!\left(\frac1{n^2}\right), $$
we obtain
$$ \log\frac{\Gamma(x+1)}{n!} = \theta\log n+C(\theta)+O!\left(\frac1n\right), \tag{3} $$
where
$$ C(\theta) = \log\Gamma(\theta+1) + \gamma\theta + \sum_{k=1}^{\infty} \left( \log!\left(1+\frac{\theta}{k}\right) -\frac{\theta}{k} \right). \tag{4} $$
The series converges uniformly on $0\le\theta\le1$, because its terms are $O(k^{-2})$.
Now invoke Euler's product for the gamma function:
$$ \frac1{\Gamma(1+\theta)} = e^{\gamma\theta} \prod_{k=1}^{\infty} \left(1+\frac{\theta}{k}\right)e^{-\theta/k}. $$
Taking logarithms gives
$$ -\log\Gamma(1+\theta) = \gamma\theta + \sum_{k=1}^{\infty} \left( \log!\left(1+\frac{\theta}{k}\right) -\frac{\theta}{k} \right). $$
Comparing with (4),
$$ C(\theta)=0 \qquad (0\le\theta<1). $$
Hence (3) becomes
$$ \frac{\Gamma(x+1)}{n!} = n^\theta \left(1+O!\left(\frac1n\right)\right), \tag{5} $$
uniformly in $\theta$.
Combining (5) with Stirling's formula (1),
$$ \Gamma(x+1) = S(n),n^\theta \left(1+O!\left(\frac1n\right)\right). \tag{6} $$
It remains to compare $S(n)n^\theta$ with $S(x)$.
Since $x=n+\theta$,
$$ \frac{S(x)}{S(n)n^\theta} = \frac{\sqrt{x}}{\sqrt n} \left(\frac{x}{n}\right)^n e^{-\theta}. $$
Taking logarithms,
$$ \log\frac{S(x)}{S(n)n^\theta} = \frac12\log!\left(1+\frac{\theta}{n}\right) + n\log!\left(1+\frac{\theta}{n}\right) -\theta . $$
Using
$$ \log(1+u)=u-\frac{u^2}{2}+O(u^3), $$
uniformly for $0\le\theta<1$,
$$ n\log!\left(1+\frac{\theta}{n}\right) = \theta-\frac{\theta^2}{2n} +O!\left(\frac1{n^2}\right), $$
and
$$ \frac12\log!\left(1+\frac{\theta}{n}\right) = \frac{\theta}{2n} +O!\left(\frac1{n^2}\right). $$
Therefore
$$ \log\frac{S(x)}{S(n)n^\theta} = O!\left(\frac1n\right), $$
hence
$$ \frac{S(x)}{S(n)n^\theta} = 1+O!\left(\frac1n\right). \tag{7} $$
Substituting (7) into (6),
$$ \Gamma(x+1) = S(x)\left(1+O!\left(\frac1n\right)\right). $$
Since $x=n+\theta$ with $0\le\theta<1$,
$$ n=x+O(1), $$
so
$$ O!\left(\frac1n\right) = O!\left(\frac1x\right) \qquad (x\ge a). $$
Consequently,
$$ \boxed{ \Gamma(x+1) = \sqrt{2\pi x} \left(\frac{x}{e}\right)^x \left(1+O!\left(\frac1x\right)\right), \qquad x\ge a>0. } $$
The estimates are uniform in $\theta\in[0,1)$, hence uniform for all $x\ge a$. ∎