What kinds of bounds are there on the inverse factorial/gamma function? This is just a "share your knowledge" question for a funny infinite-fraction-ish bound I ran into for the inverse factorial function. And to be clear, by "inverse" I don't mean $\frac{1}{n!}$ but rather a funcion $L(n)$ such that $L(n)!\approx n$.
To keep things simple and avoid non-integer gamma stuff, let's define $L(n):\mathbb{N}\rightarrow\mathbb{N}$ to be the unique value such that
$$L(n)!\le n <(L(n)+1)!$$
In other words, $L(n)!$ is the largest factorial not greater than $n$.
What kinds of bounds can we get?
$$f(n)<L(n)\le g(n)$$
 A: If you look here and at related questions and answers, @robjohn gave the exact solution$$\color{blue}{n=\left\lceil e\exp\left(\operatorname{W}\left(\frac1{e}\log\left(\frac{\Gamma(n)}{\sqrt{2\pi}}\right)\right)\right)+\frac12 \right\rceil}$$ where $W(.)$ is Lambert function
A: We'll use Stirling's approximation in the very simple form
$$\left( \frac{n}{e} \right)^n \le n! \le \left( \frac{n+1}{e} \right)^{n+1}$$
because this reduces everything to understanding the behavior of the inverse of $f(x) = \left( \frac{x}{e} \right)^x$. Specifically this gives $f(L(n)) \le L(n)! \le n \le (L(n) + 1)! \le f(L(n) + 2)$ so $L(n) \le f^{-1}(n) \le L(n) + 2$ which gives that $L(n)$ is equal to either $\lfloor f^{-1}(n) \rfloor$ or $\lfloor f^{-1}(n) \rfloor - 1$.
$f(x)$ can be inverted as follows. Taking logarithms gives $\log f(x) = e \frac{x}{e} \log \frac{x}{e}$, which gives $W \left( \frac{\log f(x)}{e} \right) = \log \frac{x}{e}$ where $W$ is the Lambert W function. Hence
$$f^{-1}(x) = \exp \left( W \left( \frac{\log x}{e} \right) + 1 \right).$$
Now we need an identity: $We^W = x$ gives $e^W = \frac{x}{W}$. Using this above gives
$$\boxed{ f^{-1}(x) = \frac{\log x}{W \left( \frac{\log x}{e} \right)} }$$
which is more useful; now we can apply known asymptotics in the denominator, in particular getting
$$f^{-1}(x) = \frac{\log x}{\log \frac{\log x}{e} - \log \log \frac{\log x}{e} + o(1) }.$$
The Wikipedia article on the Lambert W function also mentions the identity
$$W(x) = \log \frac{x}{\log \frac{x}{\log \frac{x}{\ddots}}}$$
which follows from iterating the identity $W = \log \frac{x}{W}$.
Now let's actually test this out to see if it's any good. If we use only the first two terms of the Lambert W asymptotics we get
$$f^{-1}(10!) \approx 12.8 \dots $$
$$f^{-1}(20!) \approx 24.4 \dots $$
so it looks like we're off by a bit and need to include more terms. On the other hand, using exact values of the Lambert W function gives
$$f^{-1}(10!) = 10.9 \dots$$
$$f^{-1}(20!) = 20.8 \dots$$
which is better although we're still off by a little less than $1$.
A: The upper bound, $L(n)\le g(n)$ is easier to start with. Firstly, we can observe that any non-decreasing function $g:\mathbb{R}\rightarrow\mathbb{R}$ satisfying $x\le g(x!)$ works since, in such case, $L(n)\le g(L(n)!)\le g(n)$.
So let's specify the form of $g(n)$ a bit more as
$$g(x)=\frac{\log(x)}{\log(\hat g(L(x)))}$$
We're chosing this form since it will play nicely with Stirling's approximation. So we're looking for a $\hat g$ that will satisfy
$$x\le \frac{\log(x!)}{\log(\hat g(L(x!)))}$$
On the assumption $\hat g(L(x!))>1$ we can multiply through obtaining
$$x\log(\hat g(L(x!)))\le \log(x!)$$
And exponentiating everything we get
$$\hat g(L(x!))^x\le x!$$
From here, we'd like to get rid of the factorials. For the RHS, we can use a bound from Stirling's approximation:
$$\sqrt{2\pi x}\Big(\frac{x}{e}\Big)^xe^\frac{1}{12n}<x!$$
And for the LHS, we can simply note that by definition, $L(x!)=x$ for any positive integer $x$. Thus any non-decreasing $\hat g(x)$ satisfying
$$\hat g(x)^x\le \sqrt{2\pi x}\Big(\frac{x}{e}\Big)^xe^\frac{1}{12x+1}$$
can be made up into a bound on $L(n)$. Taking the $x$-th root of both sides of the above inequality we get
$$\hat g(x)\le (2\pi x)^\frac{1}{2x}e^\frac{1}{12x^2-x}\frac{x}{e}$$
So picking $\hat g(x)=\frac{x}{e}$ will work just fine. And all in all we have
$$L(n)\le g(n)=\frac{\log(n)}{\log(\hat g(L(n)))}=\frac{\log(n)}{\log(L(n))-1}$$
A similar but more tedious method (which I refuse to type out the LaTeX for!) can be used to find a similar lower bound giving us a sandwich on $L(n)$:
$$\frac{\log(n)}{\log(L(n))}<L(n)\le \frac{\log(n)}{\log(L(n))-1}$$
Oddly, both bounds include $L(n)$ in the denominator. And since increasing a denominator decreases its fraction (and the other way round too) we can actually substitute the upper bound into the denominator of the lower bound (and the other way round too) and the inequalities still hold:
$$\frac{\log(n)}{\log\frac{\log(n)}{\log(L(n))-1}}<L(n)\le \frac{\log(n)}{\log \frac{\log(n)}{\log(L(n))}-1}$$
Continuing this alternating substitution endlessly we get
$$\frac{\log(n)}{\log\frac{\log(n)}{\log \frac{\log(n)}{\log \frac{\log(n)}{\log(...)-1}}-1}}<L(n)\le \frac{\log(n)}{\log \frac{\log(n)}{\log \frac{\log(n)}{\log \frac{\log(n)}{\log(...)}-1}}-1}$$
I have no reason to think this useful or novel (and it's probably related to something about the Lambert-W or gamma function I wouldn't understand). But I found it fun in a party-trick sort of way.
