Powers versus factorials [SOUND]. Seen the convergence of some series that involved both powers and factorials. Seen that this series that some angles from 1 to infinity of n factorial over n over 2 to the nth power. Converges but this series, the sum n it goes from 1 to infinity of n factorial over n over 3 to the nth power diverges. Well, this says something about the relative sizes of n factorial and n over 2 to the nth power. Now, since this is a convergent series, the limit of the nth term must be equal to 0. So we know that the limit as n approaches infinity of n factorial over n over 2 to the nth power is 0. And that's also the case if we look at the limit over here. The limit of n factorial over n over 3 to the nth power as n approaches infinity is infinity. Not just because this series diverges but because of the way in which we showed this series diverge by applying the ration test. So 2 is too small. In that case, the denominator ends up overpowering the numerator. And 3 is too big. In that case, the numerator ends up overpowering the denominator. These two forces are balanced. When two and three are replaced by e. So if I look at this sequence, the sequence a sub n equals n factorial over n over e to the nth power, in that case, the limit as n approaches infinity of the ratio between the n plus first and the nth term is 1. So the limit of the ratio between subsequent terms is 1. And that means if you were to look at the series and try to apply the ratio test, the ratio test would be silent in this case. But still I think this is a really interesting sequence to consider. Let me just warn that these facts do not imply that the limit of a sub n approaches infinity as 1, that's not even true. Right? But what am I trying to get at here, right? What we've seen is that n factorial must be way smaller than n over 2 to the nth power because this limit was equal to 0. We've also seen that n factorial must be a ton bigger than n over 3 to the nth power. And the question now is if n factorial is way smaller than n over 2 and n factorial's way bigger than n over 3, how then does n factorial really compare to n over e to the n? We can analyse this sequence a sub n a little bit more if we're willing to use an interval. Okay. So, let's evaluate log of n factorial, at least approximate it. Log of n factorial, that's log of 1 times 2 times 3 all the way up to n but that's log of a product which is the sum of the logs. So this is the sum, k goes from 1 to n. I'm just log of k. Now you can approximate this sum with an integral, this is approximately the integral from 1 to n. of log x dx. I gotta figure out what is this definite integral. I need to know an anti derivative for log x. But it turns out the derivative of x log x minus x is equal to log x. So there is an anti derivative of log x and I can use that anti derivative to evaluate this integral. So this integral is, let me write down the anti derivative, x. Log x minus x evaluated at n and 1 and take the difference. So this is n log n minus n, it's what I get when I plug in n, minus what I get when I plug in 1, which is 1 times log 1 minus 1. Well this is n log n minus n log 1 is 0 minus negative 1 plus 1. this is approximately n log n minus n. Now we can simplify this. Okay. So I've got. Log of n factorial is approximately n log n minus n. Let me rewrite this side. Instead of n log n I'll write that as log of n to the n. And instead of minus n I"ll write minus log e to the n. You know this is a difference of logs, which is the log of the ratio, n to the n, over e to the n. Which I could also write as log of n over e to the nth power. So I've got log of n factorial is approximately log of n over e to the nth power. So then, [LAUGH] you hope that I just conclude that n factorial is approximately n over e to the nth power. So how good is this approximation? Well, we can look at some numerical evidence, I mean, here, I calculated 10 factorial. It's about 3 times 10 to the 6th. And here I've got ten over e to the 10th power and it's not so far off. Let's try it with some bigger numbers as well. Here's 25 factorial. It's about 1.55 times 10 to the 25th. And it's 25 over e to the 25th power. Well it's 1.23 about times 10 to the 24th. That's not so terrible. This is usually called Sterling's approximation. A better approximation is this. That n factorial is approximately n over e to the nth power. Times this factor, the square root of 2 pi n and this usually goes by the name Stirling's approximation [SOUND].