Series for Pi (): A Classroom Project
Dr. Gerald Wildenberg[1][2]
Department of Mathematics, M/S/T, and Computer Science
St. JohnFisherCollege
3690 East Avenue
RochesterNY14618
Email:
Dr. Carol Freeman
Department of Mathematics, M/S/T, and Computer Science
St. JohnFisherCollege
3690 East Avenue
RochesterNY14618
Email:
Series for Pi (π) : A Classroom Project
In this paper, the authors bring together trigonometric identities, series, and computers in a project that could be used to encourage student creativity and deepen understanding of the concept of rates of convergence of series. Students frequently read about how the latest computer has calculated the famous mathematical constant to millions and even billions of places but most students do not ever produce a series of their own that converges to reasonably rapidly. This project gives them the opportunity to creatively come up with series they have developed and to compare rates of convergence of these series. Though a bit of Calculus is used in our explanations, students do not need to use any Calculus (though this could be used in a Calculus course). The main tool used in producing these series is the formula for the tangent of the sum of two angles. The purpose here is not to produce exceptionally good series but to leave the readers and their students with the techniques required to produce their own series.
Among what appeals to us pedagogically about this project are the following points:
- Mathematics and computing are combined.
- A trigonometric formula is seen in a useful application.
- The limitations of ordinary computer languages in terms of precision of numbers are illustrated.
- There is opportunity for students to use ingenuity in applying a new technique.
Before proceeding we will recall for the reader all of the mathematics beyond simple algebra used in this discussion.
≈ 3.1415926535897932384626433832795028841971693993/
75105820974944592307816406286208998628034825342117036
arctan(x) = y is precisely equivalent to: tan(y) = x (in an appropriate interval)
(where this series is convergent in the interval |x| 1).
This last series, which was first published in 1671, is sometimes called Gregory’s series.
The typical amateur attempt to calculate naively uses Gregory’s series without much thought. (We should be very much surprised if it were not the case that many of the readers have themselves tried using the following simple series at one time or another.)
Since arctan(1) = /4 we have :
Alas this mathematically correct and exceedingly elegant series is computationally useless for obtaining more than a few digits of . If we compute the first thousand terms of this last series we get: 3.1425936552+, which is incorrect in the third decimal place.
And using 100,000 terms gives us: 3.1416026536+, which is wrong in the fifth decimal place. Without belaboring the point, we can guess (or prove) that the convergence of Gregory’s series is similar to the size of the nth term. I.e., it would take 1030 terms to get to 30 places using Gregory’s Series.
It’s not hard to see that any calculation involving more than 1016 steps is impractical, even on a fast computer. (In this connection it is useful to remember that there are only about 8.64104 seconds in a day.) Thus this last series can’t possibly yield more than the first few digits of unless we’re willing to wait many lifetimes.
On the other hand, Gregory’s series can give us a method for computing (really /4). At first blush it would seem that to use Gregory’s series successfully we need to “plug in” values for x which are small and for which we know the arctan. Actually we need not know the arctangent of an angle specifically but can still be successful if we know the tangent of the sum of two angles which we’ll call and .
Consider A = tan() and B = tan() then the formula for tan(+) given at the beginning of this note yields:
Suppose tan(+) = 1. Then + = /4. From the formula above for the tangent of the sum, we have:
tan( + ) = 1 = (A + B)/(1−A∙B) We can solve for A and obtain:
Now we can let B be whatever we choose and then calculate A. A sensible choice for B is a small rational number. E.g. If B = ½ then A = 1/3. We have thus found two numbers A and B with the following properties:
- =arctan(A) and =arctan(B)
- + = /4
- |A| 1 and |B| 1. Thus we can use the series mentioned above to calculate arctan(A) and arctan(B).
That is, we have proved the identity: /4 = arctan(1/2) + arctan(1/3).
So, we now use Gregory’s series (twice) to compute arctan(A) + arctan(B) = + = /4.
/4= arctan(1/2) + arctan(1/3)
= (1/2) – (1/2)3/3 -(1/2)5 /5 - (1/2)7 /7. . .
+ (1/3)/3 - (1/3)3 /5 + (1/3)5 /5 - (1/3)7 /7 . . .
Here are the results of summing the first few terms.
Table 1
Number of terms. / Partial sums for arctan(1/2) + arctan(1/3)1 / 3.3333+
2 / 3.1172+
3 / 3.1455+
4 / 3.1408+
5 / 3.1417+
6 / 3.141561+
7 / 3.14159934+
8 / 3.1415911843+
9 / 3.1415929813+
10 / 3.1415925796+
20 / 3.141592653589757+
As we can see this is a huge improvement over the simplistic use of Gregory’s series. A historical note:
Euler used /4 = arctan(1/2) + arctan(1/3) to compute to 20 places.
Our last computation is very far from the best we can do. We can now easily reapply the same trick used to obtain the previous identity to improve the convergence speed of the series.
implies that. If we chose B=1/3 we get A = 1/7. Thus we have a new identity: arctan(1/2)=arctan(1/3)+arctan(1/7). Combining this with the previous identity gives:
/4 = 2 arctan(1/3) + arctan(1/7).
Using this technique one more time: and if we choose B=1/7 we get A=2/11.
Combining the result of this, namely arctan(1/3) = arctan(1/7) + arctan(2/11) with
/4 = 2 arctan(1/3) + arctan(1/7) gives: /4 = 3arctan(1/7) + 2arctan(2/11).
Since 1/7 and 2/11 are smaller than the 1/2 and 1/3 used to obtain the values in Table 1, we can anticipate better results from using the series obtained from /4 = 3arctan(1/7)+ 2arctan(2/11). (This is because the terms being raised to a power of both of the new series are smaller, implying faster convergence.) These results are in Table 2.
Table 2Number of terms. / Partial sums for 3arctan(1/7)+2arctan(2/11)
1 / 3.1688+
2 / 3.1411+
3 / 3.141602+
4 / 3.14159243+
5 / 3.1415926592+
6 / 3.141592653438+
7 / 3.1415926535940+
8 / 3.141592653589671+
9 / 3.141592653589796+
10 / 3.14159265358979313+
20 / 3.141592653589793238462643383279419325+
As can be observed there is a fairly rapid convergence to .
The reader has now seen enough examples to construct his own identities and his own series. Note that there is no need to stick to “B values” which are fractions with numerator 1. Also note that it is in no way essential to find identities involving two arctan expressions; longer identities are easily found and the associated series may converge very rapidly. Among those which have been used at one time or another are:
/4 = 5arctan(1/7) + 2arctan(3/79) and
/4 = 4arctan(1/5) – arctan(1/239).
Before running over to the nearest computer terminal to try implementing these ideas one needs to consider the problem of doing calculations in high precision arithmetic. For the calculations used in this note the UNIX facility “bc”, which is a front end for another UNIX facility “dc”, sufficed. Here is a sample of bc which can serve as an introduction for those unfamiliar with it. Since it is very similar to C++, it should offer few problems. And, most importantly, now that LINUX is becoming widespread, many readers will be able to run this.
/* Calculate pi using the following formula*/
/* pi/4 = arctan(1/7) + 2*arctan(1/3) */
/*Scale sets number of decimals places. */
scale = 90
/* t = total of series */
t = 0
/* s= sign of the term */
s=1
/* p[i] = i^n ; n starts with value n=1 */
/* Use subscripts because bc variable names are very limiting */
p[3] = 3
p[7] = 7
for ( i = 0 ; i < 50 ; i++){
n = 2 * i + 1
x=2/(p[3])
x=x+1/p[7]
x = s*(1/n)x
t = t + x
p[3] = p[3]*9
p[7] = p[7]*49
s = -s
/* Next two lines just print. */
i+1
4*t
}
quit
Tools for doing arbitrarily high precision arithmetic are also available for Windows. One such is Mathematica. The following excerpt from a Mathematica session illustrates how Mathematica could be used to test series for .
x=1/3
Sum[((-1)^(i+1))*(x(2i-1))/(2i-1),{i,1,30}]
3922581103424956172549296665504903523435668370774
12191373254292339600420899177854776357704108212425
x=1/2;
Sum[((-1)^(i+1))*(x^(2i-1))/(2i-1),{I,1,30}]
80940053035397672658061262698657109461589
174572350776981893282099067503147954995200
N[4(%+%%%),50]
3.14159265358979323843974665360688042118948666360494
Note that other computer algebra systems, such as Maple, can also be used for these calculations.
[1] This author wishes to thank University of the West of England, BristolEngland, for support and use of computer facilities during January to May of 2001 when some of the work on this paper was done.
[2] All correspondence to Dr. Wildenberg