# Understanding the upper and lower bounds of the error estimate in Stirling's Approximation

Based on the Wikipedia article on Stirling Approximation:

$n! = \sqrt{2 \pi n} \left(\frac{n}{e}\right)^n e^{\lambda_n}$

where $\frac{1}{12n+1} < \lambda_n < \frac{1}{12n}$

How would this apply to a difference of logarithms.

For example, if I am estimating the error for $\ln(\lfloor\frac{n}{2}\rfloor!) - \ln(\lfloor\frac{n}{3}\rfloor!)$, would the error estimate then be:

$\ln(\sqrt{2 \pi \frac{n}{2}} \left(\frac{n}{2e}\right)^{\frac{n}{2}}) - \ln(\sqrt{2 \pi \frac{n}{3}} \left(\frac{n}{3e}\right)^{\frac{n}{3}}) + \ln(e^{\lambda_n})$

where $\frac{1}{12n+1} < \lambda_n < \frac{5}{12*(\frac{n}{6})}$

where the $5$ comes from $(\frac{n}{2} + \frac{n}{3})/\frac{n}{6}$

Thanks!

-
There are easier forms of Stirling's approximation for $\log n!$ (sometimes known as the "weak Stirling approximation"). If you can get your hands on effective versions of these bounds, you may have an easier time –  A Walker Apr 10 '13 at 22:29
Thanks for the info. I read up more on Stirling's approximation and now I feel more comfortable with the above. The only issue I hit was dealing with floor functions. Stirling's approximation worked as expected only when I used $\lfloor\frac{x}{2}\rfloor$. I'll check up on the Weak Stirling approximation to see that helps as you suggest. –  Larry Freeman Apr 11 '13 at 13:34

Stirling's approximation reads $n!=u_n\mathrm e^{\lambda_n}$ with $u_n=\sqrt{2\pi n}(n/\mathrm e)^n$ and $12n\lt1/\lambda_n\lt12n+1$ hence, for every $k$ and $\ell$, $$\log(k!)-\log(\ell!)=\log(u_k)-\log(u_\ell)+\lambda(k,\ell),$$ where $\lambda(k,\ell)=\lambda_k-\lambda_\ell$ is such that $$\frac1{12k+1}-\frac1{12\ell}\lt\lambda(k,\ell)\lt\frac1{12k}-\frac1{12\ell+1}.$$ In particular, $$|\lambda(k,\ell)|\lt\frac1{12\min\{k,\ell\}}.$$