Is there an inverse to Stirling's approximation?
Solution 1:
It is better to start with $$ x! \approx \left( {\frac{{x + \frac{1}{2}}}{e}} \right)^{x + \frac{1}{2}} \sqrt {2\pi } . $$ Setting $$ y = \left( {\frac{{x + \frac{1}{2}}}{e}} \right)^{x + \frac{1}{2}} \sqrt {2\pi } , $$ we find $$ \frac{1}{e}\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right) = \frac{{x + \frac{1}{2}}}{e}\log \left( {\frac{{x + \frac{1}{2}}}{e}} \right) = \exp \left( {\log \left( {\frac{{x + \frac{1}{2}}}{e}} \right)} \right)\log \left( {\frac{{x + \frac{1}{2}}}{e}} \right). $$ We use the Lambert $W$-function defined by $W\left( z \right)e^{W\left( z \right)} = z$ for $z>0$. From the above we see that $$ \log \left( {\frac{{x + \frac{1}{2}}}{e}} \right) = W\left( {\frac{1}{e}\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right)} \right). $$ Whence $$ \frac{{x + \frac{1}{2}}}{e} = \exp \left( {W\left( {\frac{1}{e}\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right)} \right)} \right) = \frac{{\frac{1}{e}\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right)}}{{W\left( {\frac{1}{e}\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right)} \right)}}, $$ i.e., $$ x = \frac{{\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right)}}{{W\left( {\frac{1}{e}\log \left( {\frac{y}{{\sqrt {2\pi } }}} \right)} \right)}} - \frac{1}{2}. $$ For example, if $y=720$ then $$ x = \frac{{\log \left( {\frac{{720}}{{\sqrt {2\pi } }}} \right)}}{{W\left( {\frac{1}{e}\log \left( {\frac{{720}}{{\sqrt {2\pi } }}} \right)} \right)}} - \frac{1}{2} \approx 5.99658, $$ which is a very good approximation.
Solution 2:
As $n$ increases to infinity we want to know roughly the size of the $x$ that satisfies the equation $x! = n$. By Stirling $$ x^x e^{-x} \sqrt{2\pi x} \sim n $$ Just focusing on $x^x$ a first approximation is $\log n / \log\log n$. Now writing $x = \log n / \log\log n + x_1$ and solving approximately for $x_1$, this time using $x^x e^{-x}$ we get $$ x = \frac{\log n}{\log\log n} + \frac{\log n \cdot ( \log\log\log n + 1)}{(\log\log n)^2} + x_2 $$ with a yet smaller $x_2$ which can be also determined by plugging this into $x^x e^{-x}$. You'll notice eventually that the $\sqrt{2\pi x}$ is too small to contribute. You can continue in this way, and this will give you an asymptotic (non-convergent) serie (in powers of $\log\log n$). For more I recommend looking at De Brujin's book "Asymptotic methods in analysis". He specifically focuses on the case of $n!$ case in one of the Chapters (don't have the book with me to check).