2
$\begingroup$

I get to begin with Stirling's approximation, for any $C \in \mathbb{Z}_{\geq 0}$, there exists some $N \in \mathbb{Z}_{\geq 0}$ such that $N > C$ and for all $n > N$: \begin{align*} &\quad \left|n! - \sqrt{2\pi n}\left(\frac{n}{e}\right)^{n}\right| \leq C \left|\frac{1}{n}\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\right| \\ &\Rightarrow -C \frac{1}{n}\sqrt{2\pi n}\left(\frac{n}{e}\right)^n \leq n! - \sqrt{2\pi n}\left(\frac{n}{e}\right)^{n} \leq C \frac{1}{n}\sqrt{2\pi n}\left(\frac{n}{e}\right)^n \\ &\Rightarrow -C \frac{1}{n}\sqrt{2\pi n}\left(\frac{n}{e}\right)^n + \sqrt{2\pi n}\left(\frac{n}{e}\right)^{n} \leq n! \leq C \frac{1}{n}\sqrt{2\pi n}\left(\frac{n}{e}\right)^n + \sqrt{2\pi n}\left(\frac{n}{e}\right)^{n} \\ &\Rightarrow \sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(-C \frac{1}{n} + 1\right) \leq n! \leq \sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(C \frac{1}{n} + 1\right) \end{align*}

Now we are in a position to make further manipulations:

\begin{align*} &\quad \sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(-C \frac{1}{n} + 1\right) \leq n! \leq \sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(C \frac{1}{n} + 1\right) \\ &\{\text{$\log$ is monotonic}\} \\ &\Rightarrow \log\left(\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(-C \frac{1}{n} + 1\right)\right) \leq \log\left(n!\right) \leq \log\left(\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(C \frac{1}{n} + 1\right)\right) \\ &\{\text{take the average of the upper ($U(n)$) and lower bounds ($L(n)$)}\} \\ &\{\text{$\log(n!) \approx f(n)$ means $|f(n) - \log(n!)| \leq K \left[U(n) - L(n)\right]$, where $0 \leq K \leq 1$}\} \\ &\Rightarrow \log(n!) \approx \frac{1}{2}\log\left(\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(C \frac{1}{n} + 1\right)\right) + \frac{1}{2}\log\left(\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(-C \frac{1}{n} + 1\right)\right) \\ &\Rightarrow \log(n!) \approx \frac{1}{2}\left(\log\left(\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(C \frac{1}{n} + 1\right)\right) + \log\left(\sqrt{2\pi n}\left(\frac{n}{e}\right)^n\left(-C \frac{1}{n} + 1\right)\right)\right) \\ &\Rightarrow \log(n!) \approx \frac{1}{2}\log\left((\sqrt{2\pi n})^2\left(\frac{n}{e}\right)^{2n}\left(C \frac{1}{n} + 1\right)\left(-C \frac{1}{n} + 1\right)\right) \\ &\Rightarrow \log(n!) \approx \frac{1}{2}\log\left(2\pi n\left(\frac{n}{e}\right)^{2n}\left(\frac{-C^2}{n^2} + 1\right)\right) \\ &\Rightarrow \log(n!) \approx \frac{1}{2}\log\left(2\pi n\right) + \frac{1}{2}\log\left(\frac{n^{2n}}{e^{2n}}\right) + \frac{1}{2}\log\left(1 - \frac{C^2}{n^2}\right) \\ &\Rightarrow \log(n!) \approx \frac{1}{2}\log\left(2\pi n\right) + \frac{1}{2}\log\left(n^{2n}\right) - \frac{1}{2}\log\left(e^{2n}\right) + \frac{1}{2}\log\left(1 - \frac{C^2}{n^2}\right) \\ &\Rightarrow \log(n!) \approx \frac{1}{2}\log\left(2\pi n\right) + n\log\left(n\right) - n\log\left(e\right) + \frac{1}{2}\log\left(1 - \frac{C^2}{n^2}\right) \\ &\Rightarrow \log(n!) \approx n\log\left(n\right) - n + \frac{1}{2}\log\left(2\pi n\right) + \frac{1}{2}\log\left(1 - \frac{C^2}{n^2}\right) \end{align*}

From here I could expand $\log(1 + x)$ about $x = 0$ (note that $0 < \frac{C^2}{n^2} < 1$, as $C < n$, and $0 < n, C$, and also $C^2/n^2$ is pretty close to $0$ most of the time, as $n > C$). The first term of the Taylor series expansion for $\log(1 + x)$ about $x = 0$ is simply $x$.

\begin{align*} &\quad \log(n!) \approx n\log\left(n\right) - n + \frac{1}{2}\log\left(2\pi n\right) + \frac{1}{2}\log\left(1 - \frac{C^2}{n^2}\right) \\ &\Rightarrow \log(n!) \approx n\log\left(n\right) - n + \frac{1}{2}\log\left(2\pi n\right) - \frac{C^2}{2n^2} \end{align*}

But this seems to suggest my error is $O(1/n^2)$? Isn't this approximation supposed to be $O(1/n)$? Please advise on where I went wrong.

$\endgroup$
  • $\begingroup$ (In your last line you probably want to say $\Theta(1/n)$, since $O(1/n^2)$ is technically (a subset of) $O(1/n)$; but yes, the next term should be $1/(12n)$. Your error comes when you take the average of the upper and lower bounds, because they are approximations rather than exact terms, and there's no reason to believe that the real result lies 'precicely' in the middle. The best you can 'actually' do there (and that step is wholly unnecessary) is to say that the multiplying factor there is $\approx (1-O(1/n))(1+O(1/n))$ and this is only in $1+O(1/n)$. $\endgroup$ – Steven Stadnicki Jan 22 '18 at 20:15
  • $\begingroup$ @StevenStadnicki I don't see how I assume that the result is precisely in the middle? See how I define $\log(n!) \approx f(n)$. $\endgroup$ – user89 Jan 22 '18 at 20:16
  • $\begingroup$ You say 'take the average of the upper and lower boundss', and that average is where you lose the $1/n$ term, but you don't explain why you feel like you can take that average or what that average does. $\endgroup$ – Steven Stadnicki Jan 22 '18 at 20:21
  • $\begingroup$ Related: math.stackexchange.com/questions/94722/stirlings-formula-proof/… $\endgroup$ – Jack D'Aurizio Jan 22 '18 at 20:37
  • $\begingroup$ @JackD'Aurizio Very vaguely related, as I start with what question is attempting to prove? $\endgroup$ – user89 Jan 22 '18 at 21:30
2
$\begingroup$

Everything you've written here is 'correct' — but let's take a closer look at what it means. Your definition of $\approx$ says: "$\log(n!)\approx f(n)$ means that $\left|f(n)-\log(n!)\right|\leq K (U(n)-L(n))$ for some $0\leq K\leq 1$". And we have $L(n) = n\log n-n+\log(2\pi n)+\log(1-\frac Cn)$ and $U(n)=n\log n-n+\log(2\pi n)+\log(1+\frac Cn)$. So the difference between these terms — the bound you've put on the 'quality' of $\approx$ — is $\log(1+\frac Cn)-\log(1-\frac Cn)$. But the best you can say about this is that it's $O(\frac1n)$, so that's what your result is: $\log(n!)\in n\log n-n+\log(2\pi n)-\frac{C^2}{2n^2}+O(\frac1n)$. And now there's no point in including the $-\frac {C^2}{2n^2}$ term, because the $O(\frac1n)$ term 'overwhelms' it.

$\endgroup$
  • $\begingroup$ Ah, this makes sense. Can you point me to a resource that I should read to understand why $\log(1 - (1/n))$ is $O(1/n)$? $\endgroup$ – user89 Jan 23 '18 at 0:52
  • 1
    $\begingroup$ @user89 I can't point to a specific resource, but probably the most useful is just the Taylor series, which says that $\log(1+x)\in x+O(x^2)$ (as $x\to 0$). $\endgroup$ – Steven Stadnicki Jan 23 '18 at 1:00
  • $\begingroup$ Right, thanks! That totally makes sense. $\endgroup$ – user89 Jan 23 '18 at 1:15
1
$\begingroup$

Nothing justifies that a function is equivalent to the average of the left and right-hand sides in an inequality.

$n^2<n^3<n^4$ but that doesn't make $n^3\sim \dfrac{n^2+n^4}{2}$.

Just after you use the monotonicity of $\log$ you can already conclude by saying that $\log(1+\frac{C}{n})\leq \frac{C}{n}$.

$\endgroup$
  • $\begingroup$ I do not ever claim that a function is equivalent to the average of the left and right hand sides of the inequality. I simply claim that the function is close to the average of the left and right hand sides of the inequality. How close? I give a conservative estimate of at most |upperbound - lowerbound| close (but it is more likely to be at most 1/2 |upperbound - lowerbound| away). $\endgroup$ – user89 Jan 22 '18 at 21:36
  • $\begingroup$ All right. The second part of my answer still applies though. $\endgroup$ – Arnaud Mortier Jan 22 '18 at 22:07
  • $\begingroup$ @user89 If it's 1/2 (upperbound-lowerbound) away, that difference is still $\theta(1/n)$; both your upper and lower bounds are that far away from their center. $\endgroup$ – Steven Stadnicki Jan 22 '18 at 22:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.