 Hello students. Welcome to this course on Modeling Stochastic Phenomena. In this course we will be formulating various problems through mathematical equations. These equations could be differential equations, there could be difference equations and so on. Whenever possible we will be trying to develop analytical solutions to these equations and for that we require several mathematical tools. Many of those tools we will develop as we go along this lecture and as and when the situation requires it. In this present lecture some of those mathematical tools will be discussed. First tool that we will focus on is about factorial function specifically the so called the Sterling's approximation, Sterling's approximation to n factorial. The factorial function occurs quite frequently in statistical physics and in stochastic modeling. It is also sometimes called a gamma function when n is not an integer or in general whether n is integer or non integer a representation called a gamma function is used. We know that this n factorial as we understand it it increases as n increases. In some problems it becomes necessary to know the functional form through which n factorial increases as n increases. Very often we say that our function increases exponentially by that we often mean it is a very rapid increase. In fact, n factorial is a function which increases much faster than an exponential also and to see this behavior it is necessary to specifically focus on how that function behaves for large values of n. Such approaches are called asymptotic approximations in mathematical sciences. So, we basically perform such an asymptotic approximation and that is called the Sterling's approximation. So, let us begin with the definition of a factorial when n is an integer. So, we know that n factorial is defined as n into n minus 1 up to n equal to 1. There is a there is a functional representation in in the form of an integral for this n factorial. For example, the functional representation is given as follows it is an integral from 0 to infinity of x to the power n e to the power minus x dx. This representation for n n factorial can be further generalized even if n is not an integer and that is then called a gamma function. In general when n is integer one writes the gamma function as gamma n plus 1 equal to n factorial. If n is not an integer then one can write for example, gamma here nu let us say nu plus 1 then 1 1 there is no meaning in saying it as a nu factorial, but instead an integral representation of the type 0 to infinity x to the power nu e to the power minus x dx. This is valid because the integral exists and will give you a definite value. However, this representation strictly is valid for all nu greater than minus 1 strictly greater it should not include minus 1 then it is not valid. Now, let us revert back to the integral representation as we gave in the for n factorial. To see that we can just practice ourselves for let us say 2 factorial. We know that 2 factorial is 2 this 2 into 1 which is 2 which is according to the representation will be x square e to the power minus x dx. We can integrate these by parts and confirm that it is indeed true because we now do a power integration by u dv method. So, we differentiate the first term x square which is 2 x. So, the first part is x square and you integrate this term which is minus e to the power minus x evaluated at 0 and infinity and the second one will be this integral and the differential of this. Because there is already a minus sign it will be plus here and the differential of x square will be twice will come and then it will be 0 to infinity x e to the power minus x dx. Here this term at x equal to 0 it is 0 and x equal to infinity it is 0 by virtue of the fact that e to the power minus infinity is 0. So, this will then be 0 plus twice 0 to infinity x e to the power minus x dx. You can actually further do the integration by parts and note that this integral is actually equal to 1 thereby confirming the result that the integral representation is true for 2 at least that is therefore, integral 0 to infinity x square e to the power minus x dx is 2. In fact, the integral representation can be checked by integration by parts for any n. Thus for example, the integration 0 to infinity x to the power n e to the power minus x dx if you do it by parts the first term is going to be x to the power n and the integration of e to the power minus x is minus e to the power minus x evaluated at 0 to infinity and like before there will be a plus term here and here it will be n then integral n x to the power n minus 1 is the derivative of x to the power n and e to the power minus x dx. If we had identified this as with n factorial here it is going to be 0 here both the limits and this will be n and this will be basically n minus 1 factorial which is true because n factorial is n into n minus 1 factorial and by substituting different values of n we can show that it reproduces the fundamental definition of n which is true and hence the integral representation is valid for integer n for now let us first write down what is it that we want to prove. The sterling approximation specifically says that sterling's approximation specifically says that for large n for large n that is n let us say much greater than unity the factorial function n factorial can be represented as n to the power n e to the power minus n square root of 2 pi n much greater than unity. This is true even if n is not an integer if we extend the definition of factorial via gamma function extend the definition of n factorial via the gamma function representation. So, let us set out to prove this result to prove this result we write in the following form gamma n plus 1 which is how we defined n factorial of course the definition is x to the power n e to the power minus x dx we can write it in the following form x to the power n can be written as e to the power n log x this quantity can be written as e to the power n log x then that is already e to the power minus x which is not an approximation this is an exact representation. We can rewrite the same thing as gamma n plus 1 equal to 0 to infinity e to the power phi x dx where phi x depends on n also where phi x will be defined as n log x minus x. Let us look at this integral behavior of this integral when x approaches the lower limit 0 the behavior of the integral when x approaches 0 as x tends to 0 what happens to phi x phi x is n log x minus x. So, as x goes to 0 log x tends to minus infinity and hence phi x tends to minus infinity and e to the power minus infinity will be 0 hence phi x tends to minus infinity. Let us look at phi x first it tends to minus infinity at the other limit as x tends to infinity what happens to phi x now ln of plus infinity is plus infinity minus of x which also goes to infinity. So, it is basically difference of two infinities here we note that the logarithmic function diverges far more slowly as compared to a an algebraic function like x. So, x will always overtake log x no matter what the value of n is as x really goes to infinity. Hence phi x again will tend to minus infinity as x tends to plus infinity. That means, at both the end points the function phi x tends to minus infinity and we therefore, expect the function to have a form like this phi x if we plot it was tending to minus infinity at x tends to 0 and it was tending to plus infinity it was tending to minus infinity as x goes to infinity also. So, we expect phi x to have some peak in the middle. So, this is peak in phi x. So, let us therefore, estimate the peak value the reason being that when phi x tends to minus infinity the value of the integrand e to the power phi x this quantity will be 0. So, the maximum contribution to the integral will come from the maximum value of phi x. So, we sort of focus on that value and perform the integration around that value that is the idea of an approximation. So, accordingly we find the peak. So, to find the peak of phi x to find the maximum. So, that is done by first of course, we find the extremum that is phi prime x equal to 0 which implies n 1 by x minus 1 will be 0 or the point of optimum is x equal to let us say x 0 equal to n. If you take the second derivative of phi x it will be phi double prime x it will be minus of n by x square and at x equal to x naught. If you put the value x equal to x naught we should put x equal to x naught and that is going to be minus n by x naught square x naught square is n square. So, it will be minus of 1 by n. Since n is positive the second derivative is negative hence the second derivative being negative implying that the point x naught is a maximum x equal to x naught is a maximum not a minimum that is the idea. So, with this we now perform an expansion a Taylor expansion around this point of the function phi x. So, that is the next step is perform Taylor expansion of phi x x equal to x naught the Taylor expansion is we can write that is phi x phi at x equal to x naught plus x minus x naught phi prime x naught plus x minus x naught whole square by 2 in phi double prime x naught and so on. We stop at the second derivative at the moment we are basically arguing that the contribution to the integral the dominant contribution to the integral will come from those values of the integrand which lie around x naught. So, to that extent then expansion up to x minus x naught square we deem sufficient for the present to to obtain the leading contributions. Now, we see that in this expansion this term phi prime x naught is 0 because since phi prime x naught is 0 by the nature of it being a maximum point and we have already evaluated phi double prime at x naught is minus of 1 by n the expansion takes the form phi x will be phi x naught plus 0 the second term minus of x minus x naught whole square divided by 2 n this is of course, higher order term x minus x naught cube of the order of x minus x naught cube which we tend to neglect. So, with this expansion we have a representation for gamma n plus 1 or n factorial for large n we can write it as 0 to infinity this is what we defined will now this is by definition. So, it is true and it will now approach 0 to infinity e to the power phi x naught minus x minus x naught whole square by 2 n dx. We can take out e to the power phi x naught which is x naught is n. So, it will be e to the power phi n and this integral now will be e to the power minus of x minus n whole square by 2 n x from 0 to infinity dx. To evaluate the integral we do a transformation x minus n equal some new variable let us say u then our function becomes gamma n plus 1 equal to e to the power phi x naught which is phi n. Now, the limits of u if you go back we see that if x equal to 0 it will be minus n x equal to infinity it will be infinity. So, it will be minus n to infinity e to the power minus u square by 2 n and dx will be d u as n tends to infinity the value of this integral will not be much affected if we set the lower limit as minus infinity. So, as n tends to infinity the lower limit may be set to infinity set to minus infinity since n tends to infinity. So, accordingly we will have equal to e to the power what is phi n x naught log x naught. So, it is n log of n minus n and this integral will be now minus infinity to infinity e to the power minus u square by 2 n d u. This integral is the well known Gaussian integral a Gaussian integral has a value we can take it from literature. In fact, most generally it is written as if sigma square is used as the variance of the distribution or function then this is sigma root 2 pi in our case sigma square is n. So, sigma is root n. So, it will become square root of 2 pi n since sigma square equal to n in our case. So, our integral takes the form this is gamma n plus n will be e to the power n log n e to the power n log n is n to the power n and this is e to the power minus n and the Gaussian integral is square root of 2 pi n and by definition we know that that is n factorial. Hence, we obtain the approximation n factorial equal to n to the power n e to the power minus n square root of 2 pi n as n tends to infinity. The sterling approximation is also written in the form in the after taking log on both sides it is often written as ln of n factorial is equal to n plus half log n minus n plus half ln 2 pi. You can also write like this because when you take log this is a square root of n will add n to the power half will add. So, it will n plus half ln. Actually this approximation although it is supposed to be valid for very large n works fairly well even if n is say within the first 10 values. For example, let us just obtain the values n and exact value that is n factorial for integer cases and the sterling approximation. If n is 1 this is 1 and sterling approximation will yield you 0.92214 there is an underestimate of 8 percent or so. If you put n equal to 2 exact value is 2 and we get 1.919 by using this formula n factorial representation by sterling approximation. So, 1 and so forth by the time you reach 5 the exact value is 120 and this gives you nearly 118.02. So, if you look at error it will be about 8 percent is about 7.8 percent or so, it will steadily decrease to 4.05 percent and by the time we reach 5 it comes to about 1.6 percent. So, the error beyond 5 is less than about 2 percent and it comes to about 1 percent or so by the time you reach n 10. So, this is sort of variable for most practical applications especially when we are looking at order of magnitude results. So, this is basically what sterling's approximation is all about. I would like to close this by telling that there is a small addition to sterling's approximation by further improving the integral method by improving the expansion around x equal to x naught and that leads to a corrected improved approximation beyond sterling's approximation improved sterling's approximation. We will not prove it, but just for completeness we will state that result which says that n factorial will be n to the power n e to the power minus n root 2 pi n and 1 plus 1 by 12 n and this approximation in fact, brings down the error to less than 0.01 percent by the time you reach n equal to 5 it is extremely accurate. It is quite accurate even for n equal to 5 and beyond. So, here we first introduce to the concept of asymptotic approximations. This is quite useful for understanding the behavior of solutions in large n limits and we will encounter several occasions in probability theory in random work modeling where we are going to use this result. From now on we will go to other mathematical tools which will be used in this lecture. Thank you.