Sunteți pe pagina 1din 29

Just Another Cauldron

Alexander Liu

August 2017

Abstract

Stirlings approximation is a powerful tool in various scientific fields. Created for the approximations
of large factorials (n!), the approximation has been found useful in the studies of thermodynamics and
statistical mechanics. While the derivations of Stirlings approximation and Stirlings series have been
well documented online, performing the derivation by oneself is far more exciting and tests ones under-
standings of mathematical concepts. This short article presents a four part walkthrough of Dr. Daniel
Fishmans Potions seriesessentially a complete derivation of Stirlings seriesthrough the lens of a
first-year calculus student, ultimately resulting in a fuller understanding of this mathematical jewel. The
contents have stayed true to Dr Fishmans guidelines concerning wand1 use, making this derivation both
an arithmetic and thinking exercise.

1 Also known as calculators

1
1 The Accelerating Potion
1.1 Background Work
1.1.1 Pascals Brew

Let us start with something very familiar: the first 10 rows of Pascals Triangle.

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1
1 10 45 120 210 252 210 120 45 10 1

Now we will explore an interesting sum using the numbers of the last row:

1
1 0
4 5
1 2 0
2 1 0
2 5 2
2 1 0
1 2 0
4 5
1 0
+ 1
2. 5 9 3 7 4 2 4 6 0 1
Notice that for each subsequent number in the 10th row we have shifted the units digit to the right. We
have placed a decimal after the first digit of the sum to obtain 2.5937424601. After some tinkering around,
we observe that this sum2 can be written as 1.110 .

A sum from Pascals Triangle


1.110 = 2.5937424601

2 In fact, the nth row of Pascals triangle can be written as 1.1n .

2
1.1.2 Eulers Number
1 N
We recall that Eulers Number, e, can be defined by limN (1 + N) . Our sum from Pascals Triangle
turns out to be the limit expression evaluated at N = 10. However, if we look for a value q where (1+ N1 )q = e,
we discover something quite interesting:

N = 10, q = 10.49205869
N = 100, q = 100.4991708
N = 1000, q = 1000.499917
N = 2000, q = 2000.499958

It seems as though we have arrived at a limit statement.

Experimentally discovered limit


1
limN ( ln(1+ 1
)
N ) = 0.5
N

This limit can be easily proved using Lhopitals rule. If we make the substitution x = 1/N ,

1 x ln(1 + x)
1 N =
ln(1 + N)
xln(1 + x)

d2 1
2
(x ln(1 + x)) =
dx (x + 1)2

d2 2+x
2
xln(1 + x) =
dx 2(x + 1)2

1
lim = 0.5
x0 2+x

We will now further explore this limit.

1.1.3 Values of N

We will now follow Dr. Fishmans steps for dissecting the limit definition of e.
1
1. The definition can be rewritten as e = limx0+ (1 + x) x
2. Taking the natural logarithm of both sides, 1 = limx0+ x1 ln(1 + x)
3. Using the power series for ln(1 + x), we can rewrite this equation as follows:

1 x2 x3 x4
1 = lim+ (x + + ...) (1)
x0 x 2 3 4

3
4. Substituting x = 1/N , we obtain

1 1 1 1
1 = lim N ( + + ...) (2)
N N 2N 2 3N 3 4N 4

5. Finally, by distributing N,
1 1 1
1 = lim (1 + 2
+ ...) (3)
N 2N 3N 4N 3
Note that the first value in the limit statement is 1! For small values of N , the limit statement is essentially
a very bad approximation of 1. Notice the second term, 1/2N . If we approximate e with 1.110 , we obtain
a value about 5% below e, or 1/2(10). Substituting 100 for N yields a value 0.5% beloe e, and so on.
Therefore, the second term of the seires provides the error margin for N . We will now attempt to accelerate
the approximation of e by manipulating the series to decrease the second term.

First we will calculate two benchmark values to compare with the acceleration potion.
1
1. For an error less than or equal to 1%, 2N 0.01. Therefore N 50.
1
2. For an error less than or equal to 0.01%, 2N .0001. Therefore N 5000.

1% and 0.01% values of N


N = 500, 5000

We are ready to brew an acceleration potion.

4
1.2 Acceleration
1 N
Before we begin brewing, let us review. We have determined that (1 + N) approaches e rather slowly.
Using a power of N + 0.5 seems to yield a much better approximation. We shall now use this exponent
N + 0.5 to brew our potion.
1. We start with our statement,
1 1
e = lim+ (1 + x) x + 2 (4)
x0

2. Taking a logarithm of both sides,

1 1
1 = lim ( + )ln(1 + x) (5)
x0+ x 2

3. Rewriting ln(1 + x) as a power series,

1 1 x2 x3 x4
1 = lim+ ( + )(x + + ...) (6)
x0 x 2 2 3 4

4. Substituting x = 1/N ,

1 1 1 1 1
1 = lim (N + )( + + ...) (7)
N 2 N 2N 2 3N 3 4N 4

5. Distributing,

N 1 N 1 N 1 N 1
1 = lim ( + + + + ...) (8)
N N 2N 2N 2 2 2N 2 3N 3 2 3N 3 4N 4 2 4N 4

6. And combining like terms. Notice immediately that the term 1/2N , our previous approximation, has
been cancelled.
1 1 3
1 = lim (1 + 2
3
+ ...) (9)
N 12N 12N 40N 4
We will now review our benchmark values, using 1/12N 2 as our error expression.
1
1. For an error less than 1%, 12N 2 0.01. Therefore N 3.
1
2. For an error less than .01%, 12N 2 0.0001. Therefore N 29.

1% and 0.01% values of N with acceleration


N = 3, 29

These benchmark values demonstrate the effects of the acceleration potion. More accurate approximations
of e can now be obtained with vastly smaller values of N . If we use the benchmark values obtained without
acceleration, i.e. 50, 5000, we will predict e with much greater accuracy:
1
1. 12502 = 0.00003333... will yield accuracy up to 4 decimals.
1
2. 1250002 = 0.000000333... will yield accuracy up to 6 decimals.

5
1.3 Results and Extension
1.3.1 Comparison Table

Perhaps the easiest way to observe the effects of using N + 0.5 in the limit expression is to create a table
as follows (note the value of e to 9 decimals is 2.718281828):

1 N 1 N +0.5
N (1 + N) (1 + N)
50 2.691588029 2.718370659
500 2.715568521 2.718282733
5000 2.718010050 2.718281838
50000 2.718254646 2.718281829
500000 2.718279110 2.718281828
5000000 2.718281557 2.718281828
50000000 2.718281801 2.718281828
500000000 2.718281826 2.718281828
5000000000 2.718281828 2.718281828

Notice that the right hand column becomes accurate to 9 decimals at N = 5 105 , while the original limit
definition does not achieve such accuracy until N = 5 109 . In other words, adding 0.5 to the limit exponent
allows us to achieve 9 decimal accuracy around ten thousand times faster.

1.3.2 Further Acceleration

We will now attempt to further accelerate the arrival of e by adding yet another term to the exponent in
the limit definition. We have concluded that the second term in the series expansion of ln(1 + N1 ) multiplied
by the exponent yields an approximate error for a given value of N . Therefore, we must cancel out the term
1 1
12N 2 as we did 2N by adding a term f (N ) to the exponent.
1. Write out the established limit definition, adding a term f (N ):

1 N + 1 +f (N )
e = lim (1 + ) 2 (10)
N N

2. Taking a logarithm of both sides,

1 1
1 = lim (N + + f (N ))ln(1 + ) (11)
N 2 N
1
3. Rewriting ln(1 + N) as a power series and distributing,

f (N ) 1 f (N )
1 = lim (1 + + 2
...) (12)
N N 12N 2N 2
f (N ) 1
4. Realize now that if N is set equal to 12N 2 , the next term containing f (N ) will be a cubic term. This

is our goal. Solving for f (N ),


f (N ) 1 1
= , f (N ) = (13)
N 12N 2 12N

6
1
5. Determine the new error expression using f (N ) = 12N ,

1 1 1 1 1
1 = lim (1 + + ...) = lim (1 + ...) (14)
N 24N 3 6N 3 36N 4 4N 3 N 8N 3

Our new benchmark values are calculated as follows:


1
1. For an error less than 1%, 8N 3 0.01. Therefore N 2.
2. For an error less than .01%, 8N1 3 0.0001. Therefore N 8.

1% and 0.01% values of N with more acceleration


N = 2, 8

1.4 Review
In summary, we have accelerated the arrival of e using the limit definition by adding terms to the exponent.
Using the power series for ln(1 + x), we have brewed an acceleration potion that allows us to accurately
determine the percent error for a given value N .

7
2 The Shrinking Potion
2.1 Background Work
Let us begin with a series we are now quite familiar with...

Series for ln(1 + x)


P xn (1)n1
n=1 n

We will now prepare a benchmark value as we did with the acceleration potion with the help of a calculator.
By writing a recursive program, we can conjure a running sum. Here is the program recommended by Dr.
Fishman on a TI-83 or TI-84:
:0 S
:FOR(J, 1, 1000)
:F(J) + S S
:DISP S
:PAUSE
:END
where F(J) represents the summand. Using this program, we can calculate the number of terms necessary
for the ln(1 + x) series to approximate ln(1.5) to 9 decimals.

Number of terms to evaluate ln(1 + 21 ) with an unshrunk series to 9 decimal places


25

We will now prepare two more benchmark values using the Alternating Series Theorem. Since the Maclaurin
Series for ln(1 + x) is an alternating series, the approximate error can be determined by where the series is
truncated. To approximate ln(1 + 12 ) and ln(1 + 1) to 20 decimal places:
0.5n
1. n 1020
n > 61
2. 1
n 1020
n > 1020

Number of terms to evaluate ln(1 + 12 ) and ln(1 + 1) with an unshrunk series to 20 decimal places
61, 100000000000000000001

We will now prepare the Shrinking Potion.

8
2.2 Shrinking
2.2.1 Brewing Benchmarks

Note that ln(1 + 1) can be rewritten as follows:

1 + 13 1 1
ln(1 + 1) = ln( ) = ln(1 + ) ln(1 ) (15)
1 13 3 3

Recall that the MacLaurin series for each term in the above sum will be an alternating series! This will
result in a cancellation of all terms of even degree, as it is a subtraction, and a doubling of all terms of
odd degree. This is shown below:

1 ( 1 )2 ( 1 )3 ( 1 )4 1 ( 1 )2 ( 1 )3 ( 1 )4 2 2( 1 )3 2( 1 )5
( 3 + 3 3 + ...) ( + 3 3 + 3 ...) = ( + 3 + 3 ...) (16)
3 2 3 4 3 2 3 4 3 3 5

We now have a shrunken series!

Shrunken Series for ln(1 + 1)


P 1
2 n=1 32n1 (2n1)

We will now return to our benchmark values. However, using a running sum program may be quite tedious
if our potion is not powerful enough! To check, we will use a geometric series as an upper bound for our new
series:
1. Via the ratio test, the limiting ratio for the shrunken series is r = 19 .
P 2 1 n
2. Using the first term of our shrunken series, we can now write the following geometric series: n=1 3 ( 9 ) .
Note that the series decreases more slowly than our shrunken series (compare the exponents). Thus this
series is effectively an upper bound.
3. To find our benchmark value, we will use the remainder nth partial sum for our upper bound. It is
notable to review this derivation, as it is quite satisfying:

Sn = a1 +ra1 +r2 a1 +r3 a1 ... +rn1 a1


2 3
(rSn = ra1 +r a1 +r a1 +r4 a1 ... +rn a1 )
Sn (1 r) = a1 +0 +0 +0... rn a1
a1 n
Solving for S Sn , we obtain Rn = 1r r .
4. We will now solve the following inequality to obtain our benchmark value:

2 9 1
Rn = ( )( )( )n < 1020 (17)
3 8 9

Number of terms to evaluate ln(1 + 1) with a shrunken series to 20 decimal places


21

Now admittedly, we could have obtained the same answer using a calculator pretty quickly, but its nice to
do things systematically, you know?

9
To brew the same potion for ln(1 + 12 ), we note that

1 1 + 15 1 1
ln(1 + ) = ln( 1 ) = ln(1 + ) ln(1 ) (18)
2 1 5 5 5

Writing the MacLaurin series for this difference can be easily done using the previous model...

Shrunken Series for ln(1 + 12 )


P 1
2 n=1 52n1 (2n1)

Notice the series is exactly the same apart from substituting 3 with 5. By similar logic, we can calculate the
benchmark value for this series as follows:

2 25 1
Rn = ( )( )( )n < 1020 (19)
5 24 25

Number of terms to evaluate ln(1 + 12 ) with a shrunken series to 20 decimal places


15

We can now develop a general form.

2.2.2 Final Brew

Recall that the first step is to transform the natural logarithm into a sum of logarithms. Taking a closer
look at each of our previous examples, we notice that 1 + N can be rewritten as such:
1
1+ 2N +1
1+N = 1 (20)
1 2N +1

Although the previous two examples may make the brew seemingly intuitive, the expanded sums are shown
below:
1 2 1 3 1 2 1 3 1 3 1 5
1 ( ) ( ) 1 ( ) ( ) 2 2( ) 2( )
( 2N +1 + 2N +1 ...)( + 2N +1 2N +1 +...) = ( + 2N +1 + 2N +1 ...)
2N + 1 2 3 2N + 1 2 3 2N + 1 3 5
(21)
Combining like terms, we have our Shrinking Potion.

The Shrinking Potion


P 1
ln(1 + N ) = 2 j=1 (2N +1)2j1 (2j1)

Armed with our Shrinking Potion, we can now enter the world of Multi-Shrink!

10
2.3 Multi-Shrink
2.3.1 Does it work?

What happens when we apply the Shrinking Potion twice? What does applying it twice look like? We
know that the Shrinking Potion turns one natural logarithm into a sum of two logarithms. What if we were
1
to split each of the terms in the sum the same way? That is, both terms containing a fraction 2N +1 . Note
the following substitutions:
1. 2(2N + 1) + 1 = 4N + 3
2. 2(2N + 1) + 1 = 4N 1
From these two statements we can write a sum showing two iterations of the Shrinking Potion:

Sum of Logarithms
1 1 1 1
ln(1 + 4N +1 ) ln(1 4N +1 ) + ln(1 + 4N +3 ) ln(1 4N +3 )

It becomes clear to us now that two iterations of the Shrinking Potion will not lead to further shrinking. The
shrinking process was the result of eliminating terms of even powers. Further shrinking a shrunken series
will insert an additional series of odd powers (i.e. one series containing 4N + 1 in the denominator and one
containing 4N + 3) instead of leading to more cancellation.
What happens, though, when the Shrinking Potion is applied an infinite number of times? We shall explore
this using a table.

2.3.2 Infinite Shrinking

We will now attempt to apply the Shrinking Potion an infinite number of times. Instead of considering
the entire series for each logarithm term, however, we will only use the first term! Recall that for ln(1 + N )
2
the first term of Shrinking Potion is 2N +1 .

Number of Shrinking Iterations The First Term(s) of the Series The Decimal Approximation
1
0 2 0.500000000
1 2( 15 ) 0.400000000
2 2( 19 + 11 1
) = 12 ( 4.5
1
+ 5.51
) 0.404040404
1 1 1 1
3 2( 17 + 19 + 21 + 23 ) = 0.405104834
1 1 1 1 1
4 ( 4.25 + 4.75 + 5.25 + 5.75 )
1 1 1 1 1 1 1
4 2( 33 + 35 + 37 + 39 + 41 + 43 + 45 + 0.405374775
1 1 1 1 1
47 ) = (
8 4.125 + 4.375 + 4.625 +
1 1 1 1 1
4.875 + 5.125 + 5.375 + 5.625 + 5.875 )
1 1 1 1
5 2( 65 + 67 + 69 + ... + 95 ) = 0.4055942508
1 1 1 1
16 ( 4.0625 + 4.1875 + ... + 5.9375 )
??? ???

11
To determine the contents of the last row, let us first realize that the number of terms doubles in each
row after the zeroeth. We can write out a general sum for the nth row based on the six rows weve seen so
far, making the contents of the last row a limit statement:

n1
2X
1 1
lim ( 2j1
) (22)
n 2n1 j=1
4+ 2n1

While it took me awhile to realize myself, perhaps you have seen the beauty of Multi-Shrink. The above
statement is reminiscent of another legendary potion, one brewed by the wizard Bernhard Riemann.
While the above limit is not as easily simplified as those used to introduce Riemann sums to calculus
studentsthe sum counter cannot be expressed as a sum of natural numbers or squaresthe six columns in
the table seem to indicate the following integral:
Z 6
1
dx (23)
4 x

We know, of course, that this yields the exact value ln(1 + 12 ). Below is the completed table:

Number of Shrinking Iterations The First Term(s) of the Series The Decimal Approximation
1
0 2 0.500000000
1 2( 15 ) 0.400000000
2 2( 19 + 111
) = 12 ( 4.5
1 1
+ 5.5 ) 0.404040404
1 1 1 1
3 2( 17 + 19 + 21 + 23 ) = 0.405104834
1 1 1 1 1
4 ( 4.25 + 4.75 + 5.25 + 5.75 )
1 1 1 1 1 1 1
4 2( 33 + 35 + 37 + 39 + 41 + 43 + 45 + 0.405374775
1 1 1 1 1
47 ) = 8 ( 4.125 + 4.375 + 4.625 +
1 1 1 1 1
4.875 + 5.125 + 5.375 + 5.625 + 5.875 )
1 1 1 1
5 2( 65 + 67 + 69 + ... + 95 ) = 0.4055942508
1 1 1 1
16 ( 4.0625 + 4.1875 n1 + ... + 5.9375 )
1
P2 1
limn ( 2n1 j=1 4+ 2j1 ) = 0.405465108
2n1
R6 1
4 x
dx

2.4 Review
In summary, we have used a arithmetical trick to rewrite a logarithm as a sum of logarithms, resulting
in a shrunken MacLaurin series which can approximate logarithm values more accurately using fewer terms.
Applying this process twice does not amplify the shrinking process. Infinite iterations, however, will lead to
a limit statement which resembles a Riemann sum.

12
3 The Transmutation Potion
3.1 Background Work
3.1.1 Exposing p-Series

Before we begin the next potion, an interesting exercise is recommended to compare the convergence rates
of p-series and geometric series3 . Using your wand, record around 100 partial sums (to 3 decimals) of the
p = 2 series after the 70th one. Notice that the thousandths place seems to converge. The exact value of
the p = 2 series is 2 /6, which is 1.644 to rounded to the thousandths. Depending on the number of terms
you have recorded, you may have not even reached 1.640 yet.

The second part of the exercise involves a geometric series. Starting with 1/, write out the first 20 terms
of a geometric series using a common ratio 1/. You will find that the thousandths place converges much
faster than that of the p-series. In fact, each decimal takes around two more partial sums to converge, as
the j scales down by a power of 10 around every two counts. As Dr. Fishman points out, the p-series
converges at such a slow rate because the limiting ratio is 1. That is, for any range of terms in a p-series,
successive terms will be almost identical, with digits changing at a near constant rate4 . For example,

P 1
First ten partial sums of j=501 j 10
1.0037, 1.9877, 2.9522, 3.8978, 4.8248, 5.7337, 6.6247, 7.4984, 8.3551, 9.1952 (all terms are on the scale of 1027 )

Every p-series is appallingly slow at converging.

3.1.2 Remainders and Accuracy

We will now explore the remainders of p-series truncated at the N th term. Recall that the convergence
of p-series and the divergence of the harmonic series5 can be proved by the Integral Test. The harmonic
R
series is divergent because it is greater than the indefinite integral 1 x1 dx. Likewise, the rest of the p-series
are convergent because they are a sum of positive, decreasing terms and are bound by definite integrals.
Notice that depending on their placement above or below a curve, p-series can be bounded above or below
an integral6 . We will use these conditions to explore the remainders of p-series truncated at the N th term.

3 This exercise is taken from Dr. Fishmans instructions.


4 Many thanks to Dr. Fishman for this explanation
5a = 1
n n
6 See Figure 1 on the next page.

13
Figure 1: p=2 series bounded above and below through Riemann sum representation.

1
Using the curve f (x) = x2 , we can write the following inequalities:
Z Z
dx dx
> RN < RN (24)
N x2 N +1 x2
Z Z
dx dx
< RN < (25)
N +1 x2 N x2
Simplifying the improper integrals, we have the following:

Remainder for the p = 2 series


1 1
N +1 < RN < N

Using this expression it may seem that we can calculate the number of terms needed for six-decimal accuracy
1
using N < 0.0000001. However, our remainder is now bound by two values instead of one upper bound. We
may estimate our remainder to be the average of these two values, thus given a p = 2 series truncated at
1
+ N1+1 1
+ N1+1
the N th value, we may write our approximation as follow: S SN + N
2 ( N1 N
2 ). Using this
expression, truncating the series at N = 1000 will provide six-decimal accuracy:
1 1
1 1000 + 1001
( ) = 0.0000004995 (26)
1000 2

This is graphically represented by Figure 2. The appropriate integral is as follows:


Z
dx 1
RN 2
= 1 (27)
N + 21 x N+ 2

14
S1000 can be calculated using a wand7 . We end up with the following accuracy:

1
S1000 + R1000 = S1000 + = 1.644934067 (28)
1000.5

2
| 1.644934067| = 1.51800... 1010 (29)
6
We discover that the accuracy of our expression is in fact much better than we expected. Recall that our

Figure 2: p=2 as a midpoint Riemann sum. Each rectangle has width w = 1.

uncertainty inequalities were calculated using the Integral Test. This means the area differences between the
Riemann sums and the region below the curve are much greater than the actual uncertainty. Similar values
can easily be calculated for the p = 4, 6 series once you understand the above. Here are the values for the a
precision of 0.5 106 for the p = 2, 4, 6 series:

Number of Terms for 0.5 106 precision


1000, 32, 10
The numbers decrease rapidly, as numbers raised to negative third
and fifth powers decrease at a much faster rate than reciprocals.

Let us review. We have explored the rate of convergence for p-series and geometric series. We have reviewed
the Integral Test and used its principles to develop a method of determining partial sums to very good
accuracy. It is time to brew our Transmutation Potion.

7 Dr. Fishman insists you chant Lente Currite Perseverantes Potiones while you the wand does its magic.

15
3.2 Transmutation
3.2.1 Magic Snakes

We will start by cutting up a magical snake (Figure 3). The snake has slithered its way up to x = N + 12 .
Using u-substitution, we will move snake chunks of length 1 all along the y-axis. Notice that the integral
expression for all pieces of the snake are bound by 21 and 1
2, thus u = x 1 N . The equation below
represents the first two cuts:
1 1
Z Z Z Z
dx 2 du 2 du dx
= + + (30)
N + 12 x2 12 (u + N + 1)2 21 (u + N + 2)2 N + 25 x2

The entire diced up snake can be represented by an infinite sum:

Prepared Snake
R dx
P R1 du
N + 21 x2= j=N +1 2 1 (u+j)2
2

Figure 3: The cutting of snakes; starting from N = 21 , segments with length 1 are moved between the interval
( 12 , 12 ). The first two iterations are shown below.

3.2.2 Brewing with Snakes

We will now use our prepared snake to brew the potion.


1. The MacLaurin series for the integrand of each snake chunk is as follows:

1 1 2u 3u2 4u3 5u4 6u5 7u6


= + + + ... (31)
(u + j)2 j2 j3 j4 j5 j6 j7 j8

16
2. Integrating each term from u = 12 to 1
2 leads to cancellation of odd exponents due to the integration
8
bounds :
1 1 1 1
+ 4+ + + ... (32)
j2 4j 16j 6 64j 8
3. Our snake has now been digested:

Digested Snake
P 1 P
du
= j=N +1 ( j12 + 4j14 + 1 1
R
j=N +1 12
2
(u+j)2 16j 6 + 64j 8 + ...)

R dx
4. Recall the original expression for the snake: N + 12 x2
. Note that the digested snake can be rewritten as
a sum of p-series via the associative and distribute properties:
Z
dx 1 X 1 1 X 1 1 X 1 1 X 1
2
= 1 = + + + + ... (33)
N + 21 x N+ 2
j2 4 j4 16 j6 64 j8
j=N +1 j=N +1 j=N +1 j=N +1

5. Finally, we can isolate the p = 2 series to obtain a partial transmutation:

Partial Transmutation
P 1 1 1
P 1 1
P 1 1
P 1
j=N +1 j 2 = N + 12
4 j=N +1 j 4 16 j=N +1 j6 64 j=N +1 j 8 ...

Notice that the partial transmutation for p = 2 has a nice solution; all coefficients of the p-series on the right
1
side are inverse powers of two. Realize that this is because MacLaurin series for (u+j)2 exhibited cancellation
of factorials in the denominators due to antidifferentiating the numerator. For p = 4 and the next series
this solution is not so quaint. To demonstrate this, let us attempt to find a general partial transmutation
for a magic snake of any power9 . Consider first a magic snake of degree p which begins at N + 12 . Using
u-substitution: Z Z 21
dx X du
p
= p
(34)
N + 21 x 2 (u + j)
1
j=N +1

To determine the MacLaurin series, we need to determine the consecutive derivatives of f (u) = (u + j)p :

f (u) = (u + j)p
f 0 (u) = p(u + j)(p+1)
f 00 (u) = p(p + 1)(u + j)(p+2)
f 000 (u) = p(p + 1)(p + 2)(u + j)(p+3)
...

The MacLaurin series of this expression is thus:

1 pu p(p + 1)u2 p(p + 1)(p + 2)u3


+ + ... (35)
jp j p+1 2!j p+2 3!j p+3
8 I spent awhile on this step because I kept trying to simplify indefinite integrals! To be perfectly clear, each term is integrated

with respect to u from 21 to 12 .


9 Dr. Fishman calls this O.W.L. work!

17
Integrating each term will again lead to cancellations of every other term, starting with the second:

1 p(p + 1) p(p + 1)(p + 2)(p + 3) p(p + 1)(p + 2)(p + 3)(p + 4)(p + 5)


+ 2 p+2 + + ... (36)
20 j p 2 3!j 24 5!j p+4 26 7!j p+6

Notice that the numerator is the product of consecutive terms, similar to a factorial. The smallest factor of
(p+i)!
each product in the numerator is p, and we can use this to simplify the numerator to (p1)! , where p + i is
the greatest factor in the numerator for a given term. If we integrate the original snake and isolate the term
p = p series, we end with the following general partial transmutation:

Partial Transmutation
P 1 1 1
P (p+2i1)! P 1
j=N +1 j p = (p1)!
(p1)(N + 12 )p1 i=1 22i (2i+1)! j=N +1 j p+2i

Now that we have a general partial transmutation, we can move on to a complete transmutation of the p = 2
series.

3.2.3 Completing Transmutation

Let us express the N th remainder of the p = N series as TN (these are our snakes). Here are the the
partial transmutations for the first four even N using our general formula:

1 1 1 1
T2 = T4 T6 T8 ...
N + 21 4 16 64
1 5 7 3
T4 = T6 T8 T10 ...
3(N + 21 )3 6 16 16
1 7 64 33
T6 = T8 T10 T12 ...
5(N + 21 )5 4 40 32
1 33 429
T8 = 3T10 T12 T14 ...
7(N + 12 )7 8 112

We have the partial transmutations for the first four even p-series remainders. It may be tempting to make
a hasty approximation and substitute the first terms of the partial transmutations for T4 , T6 , and T8 into
the partial transmutation of T2 to obtain a complete transmutation. Here is the result10 :

1 1 1 1
T2 = 1 1 3 1 5 ... (37)
N+ 2 12(N + 2 ) 80(N + 2 ) 448(N + 21 )7

Upon closer examination, however, we observe that simply using the first term is insufficient! For example,
substituting the entire T4 series instead of simply the first term will result in additional T6 , T8 , T1 0...terms
which need to be considered when making the substitution for those respective series. To illustrate this with
T6 :

1 1 1 5 1 1 1 5 1
T2 = 1 ( 1 3
T6 ...) T6 ... = 1 1 3 + 24 T6 16 T6 ... (38)
N+ 2
4 3(N + 2 ) 6 16 N+ 2 12(N + 2 )
10 This sum is not sanctioned by the Ministry of Magic

18
Notice how this drastically changes the coefficient of T6 ! If we are to write a 7th degree transmutation for
the p = 2 series we must include every instance of T4 , T6 , and T8 which appear in each substitute. We have
5 1 7
already determined that the coefficient for T6 is 24 16 = 48 . Now we may determine the coefficient of the
5th degree term:

1 1 7 1 1 1 7
T2 = 1 + ... = + ... (39)
N+ 2 12(N + 12 )3 48 5(N + 21 )5 N+ 1
2 12(N + 21 )3 240(N + 21 )5

There are four instances of T8 when T4 , T6 , and T8 are substituted: one within T4 , one within T6 , one
within the substitution of T6 into the T4 substitution, and of course T8 itself. Using the distributive property
5 1 1 1 31
we deduce the coefficient of the 7th degree term to be 96 + 64 + 64 448 = 1344 . Thus we have our
Transmutation Potion:

Complete Transmutation of a p-series


P 1 1 1 7 31
j=N +1 j 2 = N + 12
12(N + 21 )3
240(N + 12 )5
1344(N + 12 )7

19
3.3 Testing and Review
We will now see how accurate our Transmutation Potion is. Here are the first 13 partial sums of the
p-series added to T2 :
PN 1 1
N j=1 j 2 + N + 12 12(N1+ 1 )3 240(N7+ 1 )5 1344(N
31
+ 1 )7
2 2 2

1 1.644466218
2 1.644927543
3 1.644933710
4 1.644934027
5 1.644934960
6 1.644934065
7 1.644934066
8 1.644934067
9 1.644934067
10 1.644934067
11 1.644934067
12 1.644934067
13 1.644934067

Notice that each decimal takes only one or two iterations to converge! The p-series now has the same
magic as a geometric series.

In summary, we have brewed a Transmutation Potion which adds a remainder to a p-series, giving it a
rate of convergence comparable to a geometric series. We first explored the remainder of a truncated p-series
using the Integral Test and found that a midpoint approximation yielded the best accuracy. We then used
the corresponding integral for the remainder and transformed it into a power series by making it a sum of
integrals and discovered it could be expressed as a sum of p-series. By performing the same process on other
p-series, we were able to make substitutions which led to a complete transmutation of the p = 2 series.

We are now ready to brew Stirlings Potion!

20
4 Stirlings Potion
4.1 Background Work
4.1.1 Telescoping Products

And so we come to our final potion. Before we begin, note that the past potions have all dealt with sums.
We must learn a few nuances of products before we begin Stirlings Potion.
We will first consider the following product:

4 4 4 4 Y 4
(1 2
)(1 2
)(1 2
)(1 2
)... = (1 ) (40)
1 3 5 7 j=0
(2j + 1)2

If we use a wand to calculate the partial products, it is quickly evident that the limiting value is 1.

Recall the beauty of telescoping sums; a telescoping sum can be manipulated so that all terms cancel
except for the first and last. It seems that the above product is also telescoping. Notice that each factor is
a difference of squares:

2 2 2 2 2 2 2 2 1 5 3 7 5
(1 )(1 + )(1 )(1 + )(1 )(1 + )(1 )(1 + )... = (1) (3)( ) ( )( ) ( )( ) ... (41)
1 1 3 3 5 5 7 7 3 3 5 5 7

The limit of 1 is now in plain sight! Let us continue exploring products.

4.1.2 Ninja Polynomials

Many of the sums we studied in the previous potions were power series. We will now observe how
products are actually polynomials in disguise. Consider the polynomial with zeros at 2, 4, 6: f (x) =
A(x 2)(x 4)(x 6). This polynomial can be rewritten as f (x) = 48A(1 x2 )(1 x4 )(1 x6 ). If we are
given a starting condition such as f (x) = 0, we can solve the entire polynomial by solving for A! We will
now apply this fact to a special product.

4.1.3 Another Series for the Cosine Function

Let us consider a polynomial with zeros at 2 , 3 5


2 , 2 , etc. with f (0) = 1. This sounds fairly familiar...a

function which has zeros at odd multiples of 2 and has a value of 1 at x = 0 fits the description of the cosine
function very well...

3 3 3 3 2x 2x 2x 2x
f (x) = A(x )(x+ )(x )(x+ )... = A( )( )( )( )...(1 )(1+ )(1 )(1+ )... (42)
2 2 2 2 2 2 2 2 3 3
3 3 5 5
f (0) = A( )( )( )( )( )( )... = 1 (43)
2 2 2 2 2 2
Since the product of the factored out constants equal 1 we can ignore them. Thus we have the following
after simplifying terms to differences of squares:

Infinite Product Formulation of the Cosine Function


2
4x2 4x2 4x2
(1 4x
2 )(1 9 2 )(1 25 2 )(1 49 2 )...

21
Notice that if we substitute x = we obtain our product from earlier!

4 2 4 2 4 2 4 2 4 4 4 4
(1 )(1 )(1 )(1 )... = (1 2 )(1 2 )(1 2 )(1 2 )... = 1 = cos() (44)
2 9 2 25 2 49 2 1 3 5 7

This something quite marvelous;t he cosine function has some irrational solutions; we can now express

irrational numbers as the product of rational numbers! Take 2 for example. It can be rewritten as
2cos( 4 ), thus substituting
4 into our product formulation yields the following:


Infinite Product Representation of 2
1 1 1 1
2(1 4 )(1 36 )(1 100 )(1 196 )...

2
The infinite cosine formulation can also be used to prove the sum of the p = 2 series, 6 . Notice that all the
2
factors in the formulation are in terms of x . If we write these terms as a sum of coefficients, we can equate
them to the coefficient for x2 in the MacLaurin series for the cosine function11 :

X 4
= 0.5 (45)
j=0
(2j + 1)2 2


X 1 2
= (46)
j=0
(2j + 1)2 8

Notice that the above sum is simply the odd terms of the p = 2 series. Next, note the following rearrangement:

1 1 1 1 1 1 1 1 1
+ 2 + 2 + 2 + ... = ( + + + + ...) (47)
22 4 6 8 4 1 4 9 16

In other words, the even terms of the p = 2 series equate one-fourth of the total sum! If we represent this
sum as T2 we arrive at the following equation:

2 T2 2
T2 = + T2 = (48)
8 4 6

We have just proved the p = 2 series sum the same way Euler didvia a slight assumption. We have assumed
that the cosine function can be written as an infinite product. The proof of this assumption is beyond the
scope of this article12 .

4.1.4 Walliss Product


sin(x)
We will explore one last product before brewing Stirlings Potion, using the function f (x) = x ,
assuming the function equates its limit value of 1 at x = 0. This function has zeros at integer multiples of
, thus we can rewrite it as the following polynomial:

x2 x2 x2
f (x) = A(x )(x + )(x 2)(x + 2)... = (1 2
)(1 2 )(1 2 )... (49)
4 9

11 See http://mathworld.wolfram.com/Newton-GirardFormulas.html
12 See https://en.wikipedia.org/wiki/Basel_problem for other solutions

22
Note that f ( 2 ) = 2
. Substituting x =
2 into our product gives the following:

1 1 1 3 15 35 2
(1 )(1 )(1 )... = ( )( )( )... = (50)
4 16 36 4 16 36

If we invert this result and multiply by 2 we obtain an expression for . Notice that the fractions contain
both perfect squares and difference of squares, leading to a pretty neat result known as Walliss Product

4 16 36 100
2( )( )( )( )... (51)
3 15 35 99

Walliss Product
2( 21 )( 32 )( 43 )( 45 )( 65 )( 67 )( 87 )( 89 )... =

Ignoring the factor of 2, notice that the product alternates between overestimating and underestimating
with each successive partial product.

We have now explored some products and how to manipulate them. It is time to start brewing Stirlings
Potion.

23
4.2 Stirlings Potion
4.2.1 Acceleration

We will start with the factorial function. Recall the following definition: n! = 1 2 3 4 ... n. We will
now rewrite this definition using fractions:

n1
1 2 3 4 n 1 n1 Y j
n! = ( )( )2 ( )3 ( )4 ...( ) nn = nn ( )j (52)
2 3 4 5 n j=1
j + 1

1 1
Q
The fraction in -notation can be rewritten as 1+ 1j
by multiplying the numerator and denominator by j.
We can then rearrange the product to give the following:

nn
n! = Qn1 (53)
j=1 (1 + 1j )j

We see something familiar here. The limit definition for e appears in the denominator! When brewing the
Acceleration Potion we observed that this limit converges fairly slowly, but we can write the following crude
approximation:
nn nn
n! = Qn1 = = nn e1n (54)
j=1 e en1

We will now apply the Acceleration Potion. We observed the limit as n of (1 + n1 )n+0.5 approaches e
much faster. Instead of rewriting the factorial definition as a product of fractions with integer powers (Eq.
52), we will use multiples of 0.5:

1 3 2 5 3 7 4 9 5 11 n 1 n1+ 1 1
n! = ( ) 2 ( ) 2 ( ) 2 ( ) 2 ( ) 2 ...( ) 2 nn+ 2 (55)
2 3 4 5 6 n

When we rewrite this product using -notation, the term (1 + 1j )j+0.5 will materialize:
Q

n1 1
1
Y j j+ 1 nn+ 2
n! = nn+ 2 ( ) 2 = Qn1 1 j+ 12
(56)
j=1
j+1 j=1 (1 + ) j

Replacing the limit expression with e yields the following approximation:

Crude Approximation of n!
1
n! = nn+ 2 e1n

24
Let us see how our approximation compares to n!:
1
1 nn+ 2 e1n
n n! nn+ 2 e1n n!
1 1 1 1
2 2 2.081 1.041
3 6 6.329 1.055
4 24 25.49 1.062
5 120 127.0 1.067
10 3.629E6 3.902E6 1.075
20 2.433E18 2.627E18 1.080
50 3.041E64 3.293E64 1.083

The last column is the error of our crude approximation. Notice that it does not decrease as n increases.
We must construct our approximation more carefully.

We return to the following identity:


1
nn+ 2
n! = Qn1 1 (57)
j=1 (1 + 1j )j+ 2

If we now multiply each factor by e, the product expression will approach 1 as j increases. We must also
introduce a factor of e1n to compensate:

n1
1
Y e
n! = nn+ 2 e1n 1 (58)
j=1
(1 + 1j )j+ 2

Recall the rate of convergence for (1 + 1j )j+0.5 . Nine-decimal accuracy is achieved when j is on the scale
of 103 , 104 . In other words, small values of n result in inaccuracies. To account for this, we will write the
product above as two products:
1

1
Y 1 Y (1 + 1j )j+ 2
n! = nn+ 2 e1n 1 (59)
j=1
(1 + ej )j+ 2 j=n
e

Notice that the second product cancels all factors up to that containing n in the first infinite product. Now
realize that the first product has absolutely no relation with n and can be solved! We will define this product
to be C. Thus we can rewrite the above equation as follows:
1

n+ 12 1n
Y (1 + 1j )j+ 2 1
n! = Cn e Cnn+ 2 e1n (60)
j=n
e

Solving the correction factor can be done by manipulating Walliss Product. Recall that the numerators of
Walliss Product consisted of successive even numbers, the denominators of odd numbers. Inserting even
numbers into the numerators and denominators will create factorial expressions! Observe the following
manipulation:
2244 22224444 2!4 28
= = (61)
1335 12233445 4!5!

25
Notice that this transformation results in four factors of each even number in the numerator. Let us use
only two for simplicity. Consider now the following table:

n Prime Factorization of n Manipulated Form of 2 4 ... n


2 2 21 1!
4 22 22 2!
6 32 23 3!
3
8 2 24 4!
10 52 25 5!
12 3 22 26 6!
14 72 27 7!

The table reveals that the partial products of even numbers can be expressed as a product of a factorial
and power of 2. There are four of each even number in the numerator of the transformed Walliss Product.
If we model an expression off of Eq. 61 we arrive at the following statement:

Walliss Product as a Limit of a Ratio of Factorials


n!4 (2n )4
2 = limn (2n+1)!(2n)!

We will now solve for C by replacing every factorial in the above limit with the identity in Eq. 6013 . We
will also rewrite the denominator of the limit statement as (2n + 1)(2n)!2 for convenience14 :
1
1 Q (1+ 1j )j+ 2 4 n 4
(Cnn+ 2 e1n j=n e ) (2 )
= lim 1 (62)
2 n 1 Q (1+ 1j )j+ 2
(2n + 1)(Cnn+ 2 e1n j=2n e )2

1
Q (1+ 1j )j+ 2
We can use the fact that limn j=n e = 1 to greatly simplify this statement:

1
(Cnn+ 2 e1n )4 (2n )4 C 4 n4n+2 e44n 24n C 2 e2 n
= lim 1 = lim 2 4n+1 24n 4n+1
= lim (63)
2 n n+
(2n + 1)(Cn 2 e 1n )2 n (2n + 1)C n e 2 2 n 2n + 1
r
2 2
C= = (64)
e2 e
Combining this constant with our identity and manipulating the terms gives us the following statement
known as Stirlings Approximation:
1
1 j+
n Y (1 + j ) 2
n! = 2n( )n (65)
e j=n e

Here is the approximation! It is used in many physical chemistry courses when discussing statistical thermo-
dynamics15 for estimating large factorials. We will now investigate the nuances of Stirlings Approximation.
13 Not the approximation!
14 An unwanted exponent of 2n = 32 appears if we use the expression in the above box
15 I regret not having these Potions available to me sooner; Stirlings Approximation was a part of Princeton Universitys 2017

Physics Competition!

26
4.2.2 Shrinking

Stirlings Approximation is usually written without the product expression: n! = 2n( ne )n . While this
approximation is quite good for large factorials, let us explore its accuracy with smaller values of n:

n n! 2n( ne )n
1 1 0.922137
2 2 1.919004
3 6 5.836210
4 24 23.506175
5 120 118.019168
6 720 710.078185
7 5040 4980.395832
8 40320 39902.39545
9 362880 359536.8728

These approximations are fairly close due to the use of the Acceleration Potion in the approximation.
However, we neglected to use the product expression in the above table; this expression can be seen as a
correction factor, similar to a remainder for a truncated series. We will now take a closer look at this
product.

Notice that the product is in terms of n. We will denote it (n). Recall that taking the logarithm of a
product allows it to be written as a sum of logarithms. We will now attempt to simplify ln((n)):
1

Y (1 + 1j )j+ 2 X 1 1 X
ln((n)) = ln( )= ((j + )ln(1 + )) 1 (66)
j=n
e j=n
2 j j=n

Notice that there is a term ln(1 + 1j ) in the first summand. We will apply the Shrinking Potion to simplify
the expression:

X 1 2 2 2
ln((n)) = [(j + )( + 3
+ + ...) 1] (67)
j=n
2 2j + 1 3(2j + 1) 5(2j + 1)5

1
Notice now that we have a sum of quasi p-series! By transforming all the denominators into power of j + 2
and distributing, we obtain the following result:

The Correction Factor as a Sum of Series


1
P 1 1
P 1 1
P 1
ln((n)) = 12 n (j+ 1 )2 + 80 n (j+ 1 )4 + 448 n (j+ 12 )6
...
2 2

4.2.3 Transmutation

We now arrive at the final stage. Using the Acceleration and Shrinking Potions we have brewed Stirlings
Potion and expressed its correction factor as a sum of quasi p-series. We will now use our work from the
Transmutation Potion to simplify the correction factor.

27
Recall the background work done for the Transmutation Potion. We discovered that a midpoint integral
was the most accurate for determining the sum of a p-series. We will now approximate the first two sums in
the correction factor as integrals for midpoint Riemann Sums (the integrals begin at n because the remainder
1
of a p-series which begins at n + 2 was truncated at n 12 . Thus the midpoint approximation begins at n.):
Z Z
1 dx 1 1 dx 1
2
= 4
= (68)
12 n x 12n 80 n x 240n3
1 1
(n) can now be expressed as e 12n 240n3 . Let us compare the new approximations:
1 1 1
n n! 2n( ne )n e 12n 2n( ne )n e 12n + 240n3
1 1 1.002274 1.006459
2 2 2.000652 2.001694
3 6 6.000599 6.001525
4 24 24.001023 24.002586
5 120 120.002637 120.006637
6 720 720.009187 720.023076
7 5040 5040.040582 5040.101807
8 40320 40320.21779 40320.54591
9 362880 362881.3779 362883.452

Although both adjustments result in increased accuracy, the inclusion of the cubic term in the correction
factor yields a less accurate approximation of n!.

It appears as though we have made a similar mistake to the one made while brewing the Transmutation
Potion. Instead of simply substituting the appropriate integrals into the correction factor, let us cut up some
snakes. Instead of starting at n + 0.5, however, we will start at n, as we are transmutating not a normal
p-series but a quasi p-series which features (x + 0.5)p :
Z Z 1 Z Z 1
dx X 2 du dx X 2 du
2
= 1 2 4
= 1 4 (69)
n x 1 (u + j +
j=n+1 2 2) n x 1 (u + j +
j=n+1 2 2)

1
If we examine our O.W.L. work16 , we discover that j + 2 can be treated as a one term; that is, our partial
transmutations will have the same coefficients and will be quasi p-series instead of standard ones! The partial
transmutations for the above snakes will be as follows:

X 1 1 1X 1 1 X 1
1 2 = 1 4 1 6 ... (70)
j=n
(j + 2 ) n 4 j=n
(j + 2 ) 16 j=n
(j + 2)


X 1 1 5X 1 7 X 1
1 4 = 3
1 6 1 8 ... (71)
j=n
(j + 2 ) 3n 6 j=n
(j + 2 ) 16 j=n
(j + 2)

16 i.e. finding a general term for partial transmutations.

28
We can now substitute these transmutations into the correction factor, being sure to substitute the p = 4
transmutation into the p = 2 transmutation:

1 1 1 1 1 1 1 1 1 1 1
ln((n)) = ( ( 3 ...)) + ( 3 ...) + ... 3
+ 3
= (72)
12 n 4 3n 80 3n 12n 144n 240n 12n 360n3

We will now test the accuracy of this approximation of :


1 1 1
n n! 2n( ne )n e 12n 2n( ne )n e 12n + 240n3
1 1 1.002274 0.999494
2 2 2.000652 1.999957
3 6 6.000599 5.999981
4 24 24.001023 23.999982
5 120 120.002637 119.999970
6 720 720.009187 719.999928
7 5040 5040.040582 5039.999766
8 40320 40320.21779 40319.99903
9 362880 362881.3779 362879.9952

4.3 Review and Reflection


A quick look in the local potions shoppe17 will reveal that we have derived Stirlings Series. From
studying infinite products, we came across Walliss product and used it to find the correction constant for
Stirlings Approximation. We then used the Transmutation Potion to investigate the infinite product serving
as a correction factor, transforming it into an infinite series and substituting our partial transmutations.

So where should a wandering apprentice go from here? I could perhaps try to find a general expression
for the nth term in Stirlings Series. Now that I have some potions of my own, I could go to the local
potions shoppe and make some more sense out of their inventory. As a student who just spent a summer
doing research in a chemistry lab, the feelings I experienced in the lab were identical to the ones I felt
going through this derivation. Application, execution, and realizing mistakes are all part of the process that
ultimately delivers the kick in the discovery.18 Mathematics has its ups and downs, but at the end of the
day it is a science, an art, and something I will find beauty as the years go on.

5 Acknowledgments and References


My greatest thanks to Dr. Fishman for being an insightful, exciting, and informative calculus teacher for
me and other students at Montgomery High School, as well as for providing me the instructions for brewing
the above potions. I have one more class with him this year and I hope to make the best of it.

17 Wolfram Alpha or your college calculus text will do.


18 Feynman, of course! From The Pleasure of Finding Things Out.

29

S-ar putea să vă placă și