Factorial – Is the Ramanujan Factorial Approximation Optimal?

approximation-theoryfactorial

Ramanujan's famous factorial approximation, $$n!\approx\sqrt{\pi}\left(\frac{n}{e}\right)^n\root\LARGE{6}\of{8n^3+4n^2+n+\frac{1}{30}}$$ is far more accurate that the Stirling approximation when applied to numbers less than 1, but it's not quite there. What could be done to tweak it without adding to its complexity?

Update: After experimenting with Ramanujan's approximation, I've discovered this disturbing fact: apparently, the error decreases slower than the factorial increases, leading to massive integer-level errors the higher the factorial gets. Allow me to demonstrate: $$\begin{array}{r|rr}
n&\text{actual }n!&\text{Ramanujan}\\\hline
0&1&1.005513858315898906334685\\
1&1&1.000283346113497298280502\\
2&2&2.000066137639113675155990\\
3&6&6.000048293969899370824935\\
4&24&24.000067662060676644042510\\
5&120&120.000147065856635128019467\\
6&720&720.000442402580258517644894\\
7&5040&5040.001717876125295382828871\\
8&40320&40320.008220460028928349902077\\
9&362880&362880.046912269278701001557543\\
10&3628800&3628800.311612606631103904381528\\
11&39916800&39916802.364768173672637433190699\end{array}$$ At first the error reduction is apparent, but then the zeroes start to disappear, until at $11!$ the error overtakes the decimal point. Now I'm not saying the error is increasing—only that it it not decreasing fast enough. What can be done to correct this problem without radically altering the formula? I know that Ramanujan himself anticipated this problem when he wrote this inequality: $$\sqrt{\pi}\left(\frac{n}{e}\right)^n\root\LARGE{6}\of{8n^3+4n^2+n+\frac{1}{100}}<n!<\sqrt{\pi}\left(\frac{n}{e}\right)^n\root\LARGE{6}\of{8n^3+4n^2+n+\frac{1}{30}}$$ Could this hold the key? (See Formula 2.1 here)

Best Answer

Interestingly, if we do a series expansion in Mathematica

Series[(Gamma[n + 1]/Sqrt[Pi] (n/Exp[1])^-n)^6, {n, Infinity, 6}]

We get $$8 n^3+4 n^2+n+\frac{1}{30}-\frac{11}{240 n}+\frac{79}{3360n^2}+\frac{3539}{201600 n^3}-\frac{9511}{403200 n^4}-\frac{10051}{716800n^5}+\frac{233934691}{6386688000n^6}+O\left(\frac{1}{n}\right)^{13/2}.$$ This suggests that your ad hoc adjustment of the constant term is probably not strictly justified.

Related Question