Why is $n!$ so close to linear when plotted on a log scale?

705 Views Asked by At

I was considering the speed at which the factorial function grows, and thought to graph the function on a log scale. I noticed something interesting - it seems to approach a line.

I graphed $f(x) = \ln{x!}$ on Desmos, both with and without a tangent line approximation at $x=100$, and got the following graphs:

Without tangent lineWith tangent line

Although obviously the factorial function diverges as we approach the capacity of Desmos's calculation, notice that the linear model works quite well. I'm wondering if there's anything special about the factorial function that causes it to resemble a line when plotted on a log scale.

2

There are 2 best solutions below

1
On BEST ANSWER

In a sense, because a factorial is "locally exponential".

What does this mean? Factorials satisfy the recurrence relation

$$(n + 1)! = (n + 1) \cdot n!$$

while exponentials satisfy

$$b^{n + 1} = b \cdot b^n$$

for a given base $b$. Now suppose we have an $n$ that's pretty large. Then $n + 1 \approx n$. Then we have that

$$(n + 1)! \approx n \cdot n!$$

which is similar to the base-$n$ exponential's recurrence, i.e.

$$n^{n+1} = n \cdot n^n$$

In particular, we can even go out some number $k$ of increments in the same way, provided that $k$ is not too big, to get:

$$(n + k)! \approx n^k \cdot n!$$

Hence, over a range of $k$ not so large that any of them are comparable to $n$, $k \mapsto (n + k)!$ is approximately an exponential function! And thus if you plot $y = (n + x)!$ with a large $n$ and not too large range of $x$, you will get an approximately exponential curve, which then becomes likewise approximately linear in the logarithmic plot.

0
On

As suggested by March.
Sterling's formula $$ \log(n!) = n\log n - n + O(\log n) $$ so your graph has approximate slope $\log n - 1$, which changes much more slowly than $n$. Between $n=100$ and $n=200$, the slope goes from $4.6$ to $5.3$. So it looks nearly linear to the naked eye. Here, between $2000$ and $10000$ the slope ranges from $7.6$ to $9.2$.

slope