  # Ken Ward's Mathematics Pages

## Various Computing Pi Gregory Series

Section Contents

### Computing Pi

Mathematical constants can seem a bit magical when we do not know how to compute them. This page and others are about computing pi to so many places, so we know how to obtain it. There are many ways of computing pi.

### Gregory Series

The Scotsman James Gregory (1638-1675) was an exceptionally talented mathematician who is credited with the discovery of the arctangent series, called the Gregory Series (sometimes called the Leibniz series). Apparently, he knew the Binomial Theorem for fractions (before Newton published it), and had the basics of the calculus, and conceivably could have been the one to develop it. He knew Taylor's series 40 years before Taylor published it, and he also knew the series for tan x, sec x, arctan x, and arcsec x, although he is remembered only for the arctan series.

He knew the area under the curve y=1/(1+x2) between 0 and x was arctan x: [1.1]

Giving: [1.2]

So, a particular example is: [1.3]
According to Leibniz principle that an alternating series, with the absolute value of each term less than its predecessor, and its terms tending to zero, is a convergent series. The maximum error in the sum of such a series is equal to the value of the last omitted term. The Gregory series is such a series.

#### Terms needed for 4 decimal places

The series will be accurate to 4 decimal places when the last omitted term is less than 0.00005 [1.4]

Actually, rounding errors bring the needed number of terms up to 80,000-100,000 for 4 decimal places of accuracy.

#### Accelerating the series

Whilst the series is impractical for the calculation of pi, we can accelerate it. Considering the days when arithmetic had to be done by hand, it seems that the Gregory Series might be a better series to use under certain circumstances.

Taking the sum of k terms of an alternating series is less accurate than taking the sums to two consecutive terms and taking the average.
Repeating the process produces less error.

The table below shows the results of calculating the sum to 12...21 terms, and progressively taking the average of these sums.
 Term Value Average 1 Average 2 Average 3 Average 4 Average 5 Average 6 Average 7 Average 8 Average 9 12 3.0584027659273300 13 3.2184027659273300 3.1384027659273300 14 3.0702546177791900 3.1443286918532600 3.1413657288902900 15 3.2081856522619400 3.1392201350205600 3.1417744134369100 3.1415700711636000 16 3.0791533941974300 3.1436695232296800 3.1414448291251200 3.1416096212810200 3.1415898462223100 17 3.2003655154095500 3.1397594548034900 3.1417144890165900 3.1415796590708600 3.1415946401759400 3.1415922431991200 18 3.0860798011238300 3.1432226582666900 3.1414910565350900 3.1416027727758400 3.1415912159233500 3.1415929280496400 3.1415925856243800 19 3.194187909231940 3.140133855177880 3.141678256722290 3.141584656628690 3.141593714702260 3.141592465312810 3.141592696681220 3.141592641152800 20 3.091623806667840 3.142905857949890 3.141519856563890 3.141599056643090 3.141591856635890 3.141592785669080 3.141592625490940 3.141592661086080 3.141592651119440 21 3.189184782277600 3.140404294472720 3.141655076211300 3.141587466387600 3.141593261515340 3.141592559075610 3.141592672372350 3.141592648931640 3.141592655008860 3.141592653064150

The table above shows that the arithmetic can be kept relatively simple when using the Gregory series, by successively taking the averages of the sums. Using 21 terms and successively taking the average, we find pi to approximately 9 decimals (compare with 80000 terms required for 4 decimal places!)

Continuing the above scheme to 30 terms resulted in a pi estimation of 3.14159265358979, which was as far as the spreadsheet would go.

Ken Ward's Mathematics Pages

# Faster Arithmetic - by Ken Ward

Ken's book is packed with examples and explanations that enable you to discover more than 150 techniques to speed up your arithmetic and increase your understanding of numbers. Paperback and Kindle: 