## Arctan Formulae for Computing π

### Number of Terms

*My γ bakes the best π!*

To compute **π** to *d* digits; that is, to converge each individual series to **10**^{−d}; that is, compute sufficient terms so that the n^{th} term is:

__ 1 __ | ** ≤ 10**^{−d} |

**(2n-1)·q**^{2n-1} |

Taking logarithms of both sides, simplifying by discarding small values, and rearranging, we get an approximate value for **n**:

Thus to compute **π** for **d = 100000** would take approximately:

**series** | **q**^{2} | **terms** |

1/2 | 4 | 166,100 |

1/3 | 9 | 104,800 |

1/4 | 16 | 83,000 |

1/5 | 25 | 71,500 |

1/7 | 49 | 59,200 |

1/8 | 64 | 55,400 |

1/10 | 100 | 50,000 |

1/18 | 324 | 39,800 |

1/20 | 400 | 38,400 |

1/49 | 2,401 | 29,600 |

1/57 | 3,249 | 28,500 |

1/70 | 4,900 | 27,100 |

1/99 | 9,801 | 25,100 |

1/239 | 57,121 | 21,000 |

1/515 | 265,225 | 18,400 |

1/682 | 465,124 | 17,600 |

1/1985 | 3,940,225 | 15,200 |

1/12943 | 167,521,249 | 12,200 |

1/110443 | 12,197,656,249 | 9,900 |

Clearly dividing terms by, say, 57121 will cause them to get very small much faster than dividing by 16!

We can use this table to estimate approximately the relative speeds of the various formulae by computing the total number of terms required to converge all the series in each:

** formula ** | **series** | **total terms** |

2 | 1/2 1/3 | 270,900 |

3 | 1/2 1/5 1/8 | 293,000 |

4 | 1/2 1/7 | 225,300 |

5 | 1/3 1/7 | 164,000 |

6 | 1/4 1/20 1/1985 | 136,600 |

7 | 1/5 1/70 1/99 | 123,700 |

8 | 1/5 1/239 | 92,500 |

9 | 1/8 1/57 1/239 | 104,900 |

10 | 1/10 1/239 1/515 | 89,400 |

11 | 1/18 1/57 1/239 | 89,300 |

12 | 1/49 1/57 1/239 1/110443 | 89,000 |

13 | 1/57 1/239 1/682 1/12943 | 79,300 |

The last two formulae must be used with care. The typical largest integer value permited in a computer (with a 32 bit word) is around 2,000,000,000. The values of **q**^{2} either exceed this or are very close. This "overflow" error might be eliminated by dividing each "partial" term twice by **q** rather than once by **q**^{2} but this change will cause in increase in computation time by about 50% for this series.
While the number of total terms is the same, the effect would be to use 18,000 for the 1/12943 series and 15,000 for the 1/110443 series. This would make the equivalent "total terms" for comparison 94,000 for Formula 12 and 85,000 for Formula 13.

This table indicates that Formula 13 is the fastest algorithm, followed by Formulas 10, 11,and 12 with Formula 8 close behind.
In this approximation, Formula 11 is faster than Formula 8, as an example, even though it needs to compute *three* series rather than *two* because the relatively faster convergence of the "slowest" series, the 1/18.

This discussion on the relative speeds is just a first approximation. In practice, other corrections and overhead may change the actual relative speeds of the various series. The "last word" is actually to perform the various computation and time the calculations!