Summation Series for π

Infinite series which sum to π have been known for centuries. The best known is probably the so-called Leibniz formula:

π/4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - 1/11 + ...

This is also known as the arctan formula, for one proof is based on π/4=arctan(1) and the Taylor series for the arctangent function being

arctan(x) = x - x3/3 + x5/5 - x7/7 + x9/9 - ...

It has two significant problems. Firstly, it is misnamed, with Leibniz being at best the third person to discover it. The Indian mathematician Madhava of Sangamagrama found it in the fifteenth century, and independently the Scottish mathematician James Gregory discovered it in 1671. The German mathematician Leibniz rediscovered it in 1673. Incidently, Taylor series were "discovered" by Brook Taylor in 1715, although it is fairly clear that Gregory used the same method to expand arctan(x) to find the formula for π over forty years earlier.

  terms     π estimate
      10 3.0418396189294032
     100 3.1315929035585537
    1000 3.140592653839794
   10000 3.1414926535900345
  100000 3.1415826535897198
 1000000 3.1415916535897743

pi_arctan.py

The above illustrates the second significant problem. It does not converge very rapidly. Each extra digit of precision requires that one sums ten times as many terms. If one very optimistically assumes that one can sum 109 terms in a second, then to reach the 16 digits of precision that most computers use for their "double precision" floating point arithmetic would take 107 seconds, or about four months. But to reach the 34 digits of quadruple precision would take longer than the generally accepted age of the Universe, or lifetime of the Sun.

In the pre-computer era, it was incapable of giving a good estimate for π save that the convergence of this sort of alternating series can be improved by adding merely half of the last term.

  4*(1-1/3+1/5-1/7+1/9-1/11+1/13-1/15+1/17-1/19) = 3.0418396

ten terms as above, but

4*(1-1/3+1/5-1/7+1/9-1/11+1/13-1/15+1/17-1/38) = 3.14710278

Still not very impressive.

Leibniz improved

Writing the Taylor series for the arctangent function as

arctan(x) = x * ( x2/3 + x4/5 - x6/7 + x8/9 - ... )

and noting that arctan(1/√3)=π/6, gives

π=2√3*(1 - 1/(3*3) + 1/(5*32) - 1/(7*33) + 1/(9*34) - 1/(11*35)

       1 3.4641016151377544
       2 3.0792014356780038
       3 3.156181471569954
       4 3.1378528915956805
       5 3.1426047456630846
       6 3.141308785462883
       7 3.1416743126988376
       8 3.141568715941784
       9 3.141599773811506
      10 3.1415905109380797

pi_sharp.py

This series converges very much faster, and was used in 1699 by the English mathematician Abraham Sharp to compute π to 71 digits, then most accurate value of π known. It does require an accurate value of √3, but there are ways of obtaining that.

The proof that arctan(1/√3)=π/6 can be constructed by considering Pythagorous's theorem and an equilateral triangle cut into two identical right-angled triangles.

Note that for the original Leibniz formula, the ratio of the magnitude of the (n+1)th to nth term approaches one as n becomes large. That they alternate in sign means that the sum converges, but it does so very slowly. For this version, the ratio of the magnitude of the (n+1)th to nth term approaches one third.

Again one can try to improve convergence by estimating the effect of the omitted terms. Rather than multiplying the final term by one half, it now makes more sense to multiply it by three quarters.

Leibniz improved again

arctan(1) = arctan(1/2) + arctan(1/3)

There is a cunning geometric proof of this result.

So one can express π/4 as the sum of two series, each of which converges even faster than the above result based on arctan(1/√3), and with no more need to calculate √3, though one might complain that each term is almost twice the effort to calculate.

       1 3.3333333333
       2 3.1172839506
       3 3.1455761317
       4 3.1408505618
       5 3.1417411974
       6 3.1415615879
       7 3.1415993410
       8 3.1415911844
       9 3.1415929813
      10 3.1415925796

pi_arctan_23.py

Machin

In 1706 he English mathematician John Machin found the following formula.

arctan(1) = 4*arctan(1/5) - arctan(1/239)

This is one of a whole class of formulae for π called Machin formulae and based on a cunning algebraic proof.

       1 3.1832635983
       2 3.1405970293
       3 3.1416210293
       4 3.1415917722
       5 3.1415926824
       6 3.1415926526
       7 3.1415926536
       8 3.1415926536
       9 3.1415926536
      10 3.1415926536

pi_machin.py

Adding a single term to the series does better than adding an extra digit of accuracy to the answer. Another which converges slightly faster is

π/4 = arctan(1) = 5*arctan(1/7) + 2*arctan(3/79)

In 1896 the Norwegian mathematician Carl Størmer found the Machin-like formula

π = 4*arctan(1) = 176*arctan(1/57) + 28*arctan(1/239)- 48*arctan(1/682) + 96*arctan(1/12943)

which gives slightly better than three more decimal digits for each term added. Although this is now the sum of four arctangent series, note that final series, arctan(1/12943), converges much faster than the series for arctan(1/57). So there is no need to calculate the arctan(1/12943) series to even half as many terms as the arctan(1/57) series.

Ramanujan

Around 1914 the Indian genius Srinivasa Ramanujan published a formula for the reciprocal of π.

f(k)=(4*k)!*(1103+26390k)/((k!)43964k)
1/π=(2√2/9801)*(f(0)+f(1)+f(2)+...)

This, and modern related formulae, converge even faster than the arctangent-based formulae.