# A Slice of π

## Katie Steckles

Last month, mathematicians marked π day, named after the mathematical constant pi, whose value (to two decimal places) is 3.14. Pi Day is observed on March 14th (in the American calendar, 3/14) and gives mathematicians everywhere an excuse to celebrate the circle constant and share their favourite things about it.

One way to celebrate π is to try to calculate it, and with modern computers this can be done to a staggering level of precision. On π day this year, it was announced that a team of computer engineers had calculated 105 trillion digits – beating the previous record of 100 trillion digits, and taking a computer around 75 days to crunch through the calculations.

Calculations of π have been attempted throughout the ages – Wikipedia’s thorough and informative Chronology of Computation of Pi starts way back in 2000 BCE (estimated) with the Ancient Egyptian approximation of \(4 \times \big(\frac{8}{9}\big)^2\), through biblical references to π being equal to 3, all the way through to modern computational records.

These approximations suddenly get significantly more accurate when mechanical and electronic calculation devices join the fight, making it much easier to get accurate values. But the really hard-core mathematicians would much prefer to calculate π the old-fashioned way: by hand. If we check the records for the largest calculation performed prior to the invention of the desk calculator, that prize goes to a mathematician called William Shanks.

Shanks achieved a calculation of 527 digits, which he completed in 1853 – by hand, on his own, and over the course of a few decades. In order to approximate π by hand, Shanks used a formula introduced by John Machin in 1706, which states that:

\[ \frac{\pi}{4} = 4 \tan^{-1}\left(\frac{1}{5}\right)-\tan^{-1}\left(\frac{1}{239}\right) \]

The inverse tan function, sometimes also called arctan, might seem too difficult to compute by hand. But thanks to a formula first discovered in the 14th century by Indian mathematician Mādhava of Sangamagrāma, we can do this:

\[ \arctan(x) = x\ – \frac{x^3}{3} + \frac{x^5}{5}\ – \frac{x^7}{7} + \cdots \]

This means that each of the two arctans in Machin’s formula can be replaced with an infinite series of terms involving increasing powers of \(x\). Since in the formula we are using \(x\) is a fraction with 1 on the top, raising it to higher powers will just make it smaller and smaller.

So as we move along this sequence of fractions, the values will get smaller – at some point, they will be so small that they do not affect the earlier digits of π at all – so if we want to calculate, say, the first ten digits of π, we just need enough terms of this sequence to get us past the point where we are adding terms which affect those digits.

In practice, since each term has a power of the same value, this process largely involves dividing by the same value each time – the step from \(\big(\frac{1}{5}\big)^3\) to \(\big(\frac{1}{5}\big)^5\) is just division by 25, as is the step from \(\big(\frac{1}{5}\big)^5\) to \(\big(\frac{1}{5}\big)^7\). Calculating using this formula involves a lot of long division!

Machin himself used his formula, along with this arctan expansion, to compute π to 100 decimal places, but it was taken further by Shanks, who kept going to 527 digits. (He also later continued his calculations to 707 digits, but unfortunately he made a small error right at the start, meaning all of these new digits were incorrect).

More recently, Stand-up Mathematician Matt Parker has been attempting to calculate π by hand for his YouTube channel, where he posts a video every two years involving an increasingly elaborate method of calculation. Starting 11 years ago with an attempt to calculate π using pies, he has since calculated it using an out-of-control car, a pendulum, and even by counting molecules.

Two years ago, Matt attempted a hand calculation, using the same formula as William Shanks, in the town where Shanks himself performed his own calculation. This year, Matt wanted to take things one step further and attempt to beat Shanks’ record. This time, rather than using the two-term arctan formula of Machin, he employed a different one from the same mathematical family.

The term ‘Machin-like formula’ is used to describe formulae for π which have a similar form – a sum of arctan terms, with coefficients in front, which add to \(\frac{\pi}{4}\). There are hundreds of possible formulae for π in this form, including this one, attributed to Carl Størmer in 1895:

\[ \frac{\pi}{4} = 4\arctan\left(\frac1{5}\right)-\arctan\left(\frac1{70}\right) + \arctan\left(\frac1{100}\right) \]

\[ + \arctan\left(\frac1{5000}\right)-\arctan\left(\frac1{10101}\right) \]

As well as:

\[\frac{\pi}{4} = 322\arctan\left(\frac1{577}\right) +76\arctan\left(\frac1{682}\right) + 139\arctan\left(\frac1{1393}\right) \]

\[+\ 156\arctan\left(\frac1{12943}\right) + 132\arctan\left(\frac1{32807}\right) + 44\arctan\left(\frac1{1049433}\right)\]

And, if you do not mind your fractions having a non-integer on the bottom:

\[\frac{\pi}{4} = 83\arctan\left(\frac1{107}\right) +17\arctan\left(\frac1{1710}\right) +22\arctan\left(\frac1{103697}\right)\]

\[-\ 12\arctan\left(\frac1{1256744.5}\right) -22\arctan\left(\frac1{9140003941.5}\right) \]

Each of these can still be calculated using the arctan expansion, and depending on the number of arctan terms and the size of the denominators, different numbers of individual calculations will be needed. The larger the denominator, the more quickly the sequence will produce π – but the more individual calculation steps will be needed per division (long division by the square of a 10-digit number is quite a headache!)

For his own calculation, Matt chose one with seven arctan terms, which he hoped would allow him to delegate parts of the work, or “parallelise” the computation more efficiently – allowing more of the 400+ volunteers he had collected to join in and help. He picked a formula that would converge to the value of π as quickly as possible, while keeping the calculations as simple as possible. After multiplying through by 4, the formula used was:

\[\pi = 1587\arctan\left(\frac1{2852}\right) + 295\arctan\left(\frac1{4193}\right) + 593\arctan\left(\frac1{4246}\right) \]

\[+\ 359\arctan\left(\frac1{39307}\right) + 481\arctan\left(\frac1{55603}\right) \]

\[+\ 625\arctan\left(\frac1{211050}\right)\ – 708\arctan\left(\frac1{390112}\right) \]

If you would like to see the results of the attempt, Matt’s video about the 2024 calculation tells the whole story (and you may see me pop up a few times, as I was involved in the organisation).

The post A Slice of π originally appeared on the HLFF SciLogs blog.