6
$\begingroup$

I thought that $\log(n!)$ would be $\Omega(n \log n )$, but I read somewhere that $\log(n!) = O(n\log n)$.

Why?

$\endgroup$
6
  • 9
    $\begingroup$ $$\log n! =\sum_{k=1}^n \log k \leq \sum_{k=1}^n \log n$$ $\endgroup$
    – Pedro
    Commented May 4, 2012 at 16:02
  • 8
    $\begingroup$ The two statements you give are consistent. In fact both are true. $\endgroup$ Commented May 4, 2012 at 16:03
  • $\begingroup$ $\log(n!)$ is actually $\Theta(n \log n )$. See math.stackexchange.com/questions/46892/… $\endgroup$
    – lhf
    Commented May 4, 2012 at 16:12
  • $\begingroup$ @lhf Indeed, $\dfrac 1 2 n \log n$ and $n \log n$ suffice. $\endgroup$
    – Pedro
    Commented May 4, 2012 at 16:14
  • 4
    $\begingroup$ The obvious inequalities $(n/2)^{n/2} \leq n! \leq n^n$ suffice to prove $\Theta(n \log n)$. $\endgroup$
    – sdcvvc
    Commented May 4, 2012 at 16:18

2 Answers 2

12
$\begingroup$

By Stolz-Cezaro,

$$\lim_{n \to \infty} \frac{\ln (n!)}{n \ln n}=\lim_{n \to \infty} \frac{\ln ((n+1)!)- \ln(n!)}{(n+1) \ln (n+1)-n \ln n}=\lim_{n \to \infty} \frac{\ln ((n+1))}{\ln (n+1)+n [\ln(n+1)- \ln n]} $$

$$=\lim_{n \to \infty} \frac{\ln ((n+1))}{\ln (n+1)+ [\ln(1+ \frac{1}{n})^n]}=1 $$

Thus $$\ln (n!) \sim n \ln n$$

This implies both big O and Omega...

$\endgroup$
7
$\begingroup$

One idea to prove the claim :

$$\log n! =\sum_{k=1}^n \log k \leq \sum_{k=1}^n \log n=n\log n$$

The other approach would be :

$$n !\sim \frac{n^n}{e^n}\sqrt{2 \pi n}$$

From where :

$$\log n !\sim n\log n -n+\frac{1}{2} \log \pi n$$

$$\frac{\log n !}{n \log n}\sim 1-\frac 1 {\log n}+\frac{1}{2} \frac {\log \pi n} {n \log n}$$

Add: You are correct. It is important to note that $\mathrm{O}$ and $\Omega$ are not mutually exclusive. Because $n\log n$ is both $\Omega$ and $\mathrm{O}$, we say that : $$\log n! = \Theta(n \log n)$$

$\endgroup$
2
  • 1
    $\begingroup$ Thanks! Using Stirling's Approximation like that does the trick. $\endgroup$
    – David Faux
    Commented May 23, 2012 at 21:25
  • $\begingroup$ It's not a big deal but a factor of $2$ is missing inside some of the logs $\endgroup$
    – Evariste
    Commented May 10, 2020 at 17:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .