How to compute \(\pi\) with a billion digits

Introduction

To achieve a given accuracy, all calculations must be made with precision at least equal to that of the final result.

That is, to obtain \(\pi\) with a billion significant digits, all operations, multiplication, division, addition and subtraction, must be performed with arguments having at least a billion digits, so that the result of these operations have that precision.

Thus, the choice of the algorithm is very important: it must converge as quickly as possible to the result with the lowest possible number of operations.

Let us now consider a calculator that is only capable of handling numbers up to \(99\). However, to make multiplications, this calculator can use two registers and thus, represent results up to \(9999\).

With these limitations, how can it compute \(12345678\times87654321\)?

Using the features of our calculator we can organize the operations as follows:

\[ \begin{array}{rrrrrrrr} &&&& 12 & 34 & 56 & 78\\ &&&\times& 87 & 65 & 43 & 21\\ \hline &&&& 21 \times 12 & 21 \times 34 & 21 \times 56 & 21 \times 78\\ &&& 43 \times 12 & 43 \times 34 & 43 \times 56 & 43 \times 78\\ && 65 \times 12 & 65 \times 34 & 65 \times 56 & 65 \times 78\\ & 87 \times 12 & 87 \times 34 & 87 \times 56 & 87 \times 78\\ \hline &&&& 252 &714 &1176 &1638\\ &&&516 & 1462 & 2408 & 3354\\ && 780 & 2210 & 3640 & 5070\\ & 1044 & 2958 & 4872 & 6786\\ \hline & 1044 & 3738 & \raise 1.6ex {{\small 100} \atop 7598} & 2140 & 8192 & 4530 & 1638\\ \hline \raise 1.6ex {{\small 10} \atop 0} & \raise 1.6ex {{\small 38} \atop 1044} & \raise 1.6ex {{\small 77} \atop 3738} & \raise 1.6ex {{\small 22} \atop 7698} & \raise 1.6ex {{\small 82} \atop 2140} & \raise 1.6ex {{\small 45} \atop 8192} & \raise 1.6ex {{\small 16} \atop 4530} & 1638\\ \hline 10 & 82 & 15 & 20 & 22 & 37 & 46 & 38 \end{array} \]

We managed to get \(12345678\times87654321= 1082152022374638\), thus overcoming the limitations imposed by the calculator.