# How to take the derivative of $x!$

This is the problem I am trying to solve:

$$\lim_{x \to \infty} \frac{e^x x!}{x^x\sqrt{x}}.$$

I believe this is an indefinite form, thus use L'Hospitals's rule.

But the problem I am having is how to find the derivative of $x!$

• I assume you mean $\lim_{x \to \infty}$... Dec 5 '12 at 5:04
• @Jebruho yes I did.
– yiyi
Dec 5 '12 at 5:06
• wolframalpha.com/input/?i=derivative+of+x%21 Dec 5 '12 at 5:06
• Look up the Gamma function. Dec 5 '12 at 5:08
• @amzoti, I don't understand much of what wolfmanalpha returns. I just look up the terms and then get more confused. hehe
– yiyi
Dec 5 '12 at 5:08

Use the Stirling asymptotic formula, $$x!\approx x^x e^{-x}\sqrt{2\pi x}$$ for $x\gg 1$.

• is that the only method?
– yiyi
Dec 5 '12 at 5:06
• surely not, but you will need some specific results about factorials or about the gamma function. Dec 5 '12 at 5:08
• Well if you want to use L'Hospitals rule you will have to replace $x!$ with a differentiable function which happens to equal $n!$ at non-negative integers $n$, the natural way to do this is via the Gamma function. As stated, $x!$ is only defined for integers $x$, so your expression is in fact a sequence, not a function on the positive reals. Dec 5 '12 at 5:13
• @SeanGomes You seem to imply that there is an alternative method of solving this that not need L`Hospitals rule.
– yiyi
Dec 5 '12 at 6:27
• The above answer provides an example of such a method: Stirling's formula. This formula can be proven without any mention of the Gamma function. Dec 5 '12 at 6:49

Let $f(x) = \frac{e^x x!}{x^x\sqrt{x}}$. Then $\frac{f(x+1)}{f(x)} = \frac{e^{x+1} (x+1)!}{(x+1)^{x+1}\sqrt{x+1}}/ \frac{e^x x!}{x^x\sqrt{x}} = \frac{e^{x+1} (x+1)!}{(x+1)^{x+1}\sqrt{x+1}} \frac{x^x\sqrt{x}}{e^x x!} = \frac{e (x+1) x^x \sqrt{x}}{(x+1)^{x+1} \sqrt{x+1}} = \frac{e x^x }{(x+1)^x \sqrt{1+1/x}} = \frac{e }{(1+1/x)^x \sqrt{1+1/x}} = \frac{e }{(1+1/x)^{x+1/2}}$.

This and what follows is just replicating what Stirling and those who preceded him did to get "Stirling's formula".

At this point, we need to show that $(1+1/x)^{x+1/2}$ is very close to $e$ for large $x$.

Tak the logs, so we are looking at $(x+1/2) \ln(1+1/x) = (x+1/2)(1/x - 1/(2x^2) + 1/(3x^3) + ... = (1 - 1/(2x) + 1/(3x^2) + ...) + (1/(2x) - 1/(4x^2) + ...) =1 + 1/(12x^2) + ...$.

Note that the $1/2$ in $x+1/2$ allows the $1/x$ term to cancel. That is why $(1+1/x)^{x+c}$ is closest to $e$ for $c = 1/2$. For any other real $c$, $\lim \frac{e}{(1+1/x)^{x+c}} = 1$, But the product of these terms does not cenverge unless $c = 1/2$.

Exponentiating this, $(1+1/x)^{x+1/2} = e e^{1/(12x^2) + ...} = e(1+1/(12x^2) + ...)$ so $\frac{e}{(1+1/x)^{x+1/2}} = \frac{1}{1+1/(12x^2) + ...} = 1-1/(12x^2) + ...$.

In all this, the "..." represents terms of higher order in $x$.

We now know that the ratio of consecutive terms is (1) less than one (though we would have to prove that the higher order terms are smaller than the $1/(12x^2)$ term), and (2) is close enough to one that the product of $1-1/(12x^2)$ converges.

If we look at $\prod_{x=n}^m (1-1/(12x^2))$ and take the log, we find, by an analysis similar to that above, the sum of the logs converges as $m \to \infty$, so the product converges.

Since the product $\frac{f(x+1)}{f(x)}$ converges, $f(x)$ must tend to a limit. To show this, let $P_n = \prod_{x=n}^{\infty} \frac{f(x+1)}{f(x)}$. Then $P_n = 1/f(n)$ and $\lim_{n \to \infty} P_n$ exists.

This is not completely rigorous, but it can be made so, and it was. It does show why the limit exists.

Actually, Stirling's contribution was to explicitly evaluate the limit - it had previously been shown that the limit exists.

This rambling essay was done off the top of my head at 11:30 at night. I hope it helps.

• Which shows that the limit exists, but does not provide its value.
– Did
Dec 5 '12 at 8:14