[Math] Asymptotics of terms and errors in Stirling’s Approximation

asymptoticsfactorialgamma functionsequences-and-series

I have two related questions. Both are related to the asymptotics of Stirling's approximation, which is why I have included them in the same question. I will separate the questions if it is deemed necessary.

Consider Stirling's approximation.
$$n! = \sqrt{2 \pi n} \left( \frac{n}{e} \right)^n \left( 1 + O \left(\frac{1}{n} \right)\right)$$
$$\lim_{n \rightarrow \infty} \frac{n!}{\sqrt{2 \pi n} \left( \frac{n}{e} \right)^n} = 1$$
The exact terms of the expression are more precisely described by Stirling's series. Unfortunately the series is not convergent so at some point, for each particular $n$ there is a term $a_{f(n)}$ of the expansion at which point summing terms increases the magnitude of relative error.

$f : \mathbb{N}^+ \rightarrow \mathbb{N}$ and for $n$ in the domain, $f(n)$ is defined as rank at which the magnitude of the terms in the asymptotic expansion of the ratio $\frac{n!}{\sqrt{2 \pi n} \left( \frac{n}{e} \right)^n \left(1+ \frac{1}{12n} + \cdots\right)}$ begins to increase.

My first question is what is known about $f(n)$? I believe it is known that $f(n)$ is monotonically increasing. Do we know the asymptotic growth of $f(n)$? If so, is there a known simple closed form expression for $f(n)$?

My second question has to do with error rates of Stirling's approximation and it depends on the first question having been resolved. Of course it is known that in the limit the relative error of approximating the factorial of $n$ approaches $0$. However, if one were to be interested in precisely how quickly the series well approximates the function, simple convergence in the limit is not enough. I would like to know the rate of convergence for the sequence $g(n) = \sum\limits_{i=0}^{f(n)} {a_i}$ in approximating $n!$. (Here $a_i$ are terms of the Stirling series).

Best Answer

Temme's book, suggested by J.M., offers an explicit analysis of the remainder terms. However, he does not do it for the Stirling's series of $n!$, but for a similar large $n$ asymptotic expansion of $\ln n!$: $$ \ln n! \sim n(\ln n - 1) + \frac{1}{2}(\ln n + \ln 2\pi) + \frac{1}{2}\sum_{k=1}^{\infty} R_k,\quad\mbox{where}\quad R_k=\frac{B_{2k}}{k(2k-1)n^{2k-1}}\qquad (1) $$ and $B_{2k}$ denote Bernoulli numbers, see DLMF. On p.65 Temme shows that error of the truncated expansion is bounded by the magnitude of the first neglected term. Hence, the optimal truncation is at the smallest term in the sum. Keeping in mind that $B_{2k}\sim 4\sqrt{\pi k}(k/\pi e)^{2k}$, you can write $$ R_k\sim \frac{4\sqrt{k}}{\sqrt{\pi}e(2k-1)} \left(\frac{k}{\pi e n}\right)^{2k-1}. $$ The first factor is irrelevant to the leading order. It is then an easy exercise to establish that when $C$ is large, the minimum of the function $(x/C)^{2x-1}$ is achieved when $x\approx C/e$. Therefore, the optimal trancation is achieved at $k\approx\pi n$, so your $f(n)\approx\pi n$, just as obtained by robjohn.

This result may be confirmed by plotting the relative errors obtained when using expansions (1) truncated at $N$th term. The red curve is computed for $n=10$, whereas the blue curve is computed for $n=20$.

enter image description here

A similarly simple formula for $f(n)$ in the case of Stirling's series is not very likely to exist, because the late terms of Stirling's series do not decrease (or increase) in a monotonic fashion, see W. G. C. Boyd "Gamma Function Asymptotics by an Extension of the Method of Steepest Descents", Proc. R. Soc. Lond. A, 447(1931), 609-630 (1994). However, Boyd's paper does offer state-of-the-art analysis of the remainder error of the truncated Stirling's series, so it does offer an answer to your second question. Boyd also provides simple asymptotic expressions for the coefficients of Stirling's series, so you should be able to construct an asymptotic for $f(n)$ from the results given in his paper.

Related Question