4

I am curious on where the factorial $x!=\Gamma(x+1)$ passes the exponential $e^x$ for $x>0$. I first tried using Lambert $W$ and the inverse of Stirling's approximation by @Gary. Call $p$ the point at which the factorial passes the exponential. $$p=e^x\ \text{and}\ p=x!$$ The first can easily be evaluated as $x=\log(p)$ and using the Lambert $W$ function, the latter is (work by Gary) $$x = \frac{{\log \left( {\frac{p}{{\sqrt {2\pi } }}} \right)}}{{W\left( {\frac{1}{e}\log \left( {\frac{p}{{\sqrt {2\pi } }}} \right)} \right)}} - \frac{1}{2} $$ for sufficiently large $p$. Equating the two we obtain, $$\log(p) = \frac{{\log \left( {\frac{p}{{\sqrt {2\pi } }}} \right)}}{{W\left( {\frac{1}{e}\log \left( {\frac{p}{{\sqrt {2\pi } }}} \right)} \right)}} - \frac{1}{2}$$ but I can't continue further. I tried using the gamma function as well but failed to come up with anything significant. Any ideas? Thanks in advance.

bob
  • 2,167

2 Answers2

6

If you look here, you will find a superb approximation built by @robjohn. Applied to your problem $$x!=e^x \qquad \implies \qquad \color{blue}{x\sim \exp\left(2+ W\left(-\frac{\log (2 e \pi )}{2 e^2}\right)\right)-\frac 12}$$ which is $5.28081$ that is to say in a relative error of $0.18$%.

Now, using Newton-like methods of order $n$ for finding the zero of function $$f(x)=\log(x!)-x$$, the first iteration is still explicit and easy to obtain since $$\big[\log(x!)]^{(n)}=\psi ^{(n-1)}(x+1)$$

So, the results $$\left( \begin{array}{ccc} n & \text{first estimate} & \text{method} \\ 2 & \color{red}{5.2903}264120457478491 & \text{Newton} \\ 3 & \color{red}{5.2903160}763059627349 & \text{Halley} \\ 4 & \color{red}{5.2903160931}486923581 & \text{Householder} \\ 5 & \color{red}{5.2903160931197}199474 & \text{no name} \\ 6 & \color{red}{5.290316093119770}8007 & \text{no name} \\ 7 & \color{red}{5.290316093119770710}6 & \text{no name} \\ \cdots & \cdots & \\ \infty & \color{red}{5.2903160931197707107} & \text{solution} \\ \end{array} \right)$$ showing for the absolute error $$\log_{10}(|\text{error}|_n)=0.5158964 - 2.760374 \,n$$ Notice that the slope is $\sim -e$.

Edit

Making the problem more general $$x!=e^{k x}\qquad \implies \qquad \large\color{blue}{x_{(k)}\sim \exp\left(k+1 +W\left(-\frac {k+\log (2 \pi ) }{2 e^{k+1} }\right)\right)-\frac 12}$$

Some results $$\left( \begin{array}{ccc} k & \text{approximation} & \text{solution} \\ 1 & 5.28080609982 & 5.29031609313 \\ 2 & 17.5609484230 & 17.5635286436 \\ 3 & 51.6222027742 & 51.6230410442 \\ 4 & 144.964737552 & 144.965029854 \\ 5 & 399.495201639 & 399.495306705 \\ 6 & 1092.20718395 & 1092.20722222 \\ 7 & 2976.03576673 & 2976.03578075 \\ 8 & 8097.66349482 & 8097.66349997 \\ 9 & 22020.5461895 & 22020.5461914 \\ 10 & 59867.7224841 & 59867.7224841 \\ \end{array} \right)$$

For $k=10$, the absolute error is $6.96\times 10^{-7}\qquad \color{red}{\large \text{(!!)}}$

Asymptotically, $$x_{(k+1)} \sim e\,x_{(k)}$$ which is already clear looking at the numbers in the table.

1

Though an analytical solution can't be given, an approximate solution using the Lambert $W$ function can be derived by following the general steps taken by @robjohn. Start by using a slightly modified version of Stirling's formula, $\log(x!)\sim x\log(x)-x+\frac{1}{2}\log(2\pi x)$. $$\begin{align*} \log\left(\frac{e^x}{x!}\right) & \sim x-\left(x\log(x)-x+\frac{1}{2}\log(2\pi x)\right) \\ & =2x-x\log(x)-\frac{1}{2}\log(2\pi x) \\ & =-x\log\left(\frac{x}{e^2}\right)-\frac{1}{2}\log(2\pi x) \end{align*}$$ To solve the equation above for $x$ using the Lambert $W$, first multiply both sides by $-1/e^2$ to get, $$\begin{align*} -\frac{1}{e^2}\log{\left(\frac{e^x}{x!}\right)}\sim\frac{x}{e^2}\log{\left(\frac{x}{e^2}\right)}+\frac{1}{2e^2}\log(2\pi x) \end{align*}$$then subtracting $\frac{1}{2e^2}\log\left(2\pi e^2\right)$, $$\begin{align*} -\frac{1}{e^2}\log{\left(\frac{e^x}{x!}\right)}-\frac{1}{2e^2}\log\left(2\pi e^2\right)&\sim\frac{x}{e^2}\log{\left(\frac{x}{e^2}\right)}+\frac{1}{2e^2}\log(2\pi x)-\frac{1}{2e^2}\log\left(2\pi e^2\right) \\ -\frac{1}{e^{2}}\log\left(\frac{\sqrt{2\pi}e^{x+1}}{x!}\right)&\sim\frac{x}{e^2}\log{\left(\frac{x}{e^2}\right)}+\frac{1}{2e^2}\log\left(\frac{x}{e^2}\right) \\ &=\frac{2x+1}{2e^2}\log\left(\frac{x}{e^2}\right) \\ &\sim \frac{2x+1}{2e^2}\log\left(\frac{2x+1}{2e^2}\right)-\frac{1}{2e^2} \end{align*}$$hence, we end up with a form which can be expressed with the Lambert $W$ function, defined as $z=W(z)e^{W(z)}$ for $z>0$. $$\begin{align*} -\frac{1}{e^2}\log\left(\frac{\sqrt{2\pi}e^{x+1/2}}{x!}\right)&\sim\frac{2x+1}{2e^2}\log\left(\frac{2x+1}{2e^2}\right) \\ &=\log\left(\frac{2x+1}{2e^2}\right)\exp\left(\log\left(\frac{2x+1}{2e^2}\right)\right) \end{align*}$$Applying the Lambert $W$ function and solving for $x$, $$x\sim e^2\exp\left(W\left(-\frac{1}{e^2}\log\left(\frac{\sqrt{2\pi}e^{x+1/2}}{x!}\right)\right)\right)-\frac{1}{2}$$substituting $\log\left(e^x/x!\right)=0$ yields the final expression,$${x\sim e^2\exp\left(W\left(-\frac{\log\left({2\pi e}\right)}{2e^2}\right)\right)-\frac{1}{2}}.$$

bob
  • 2,167