There are many types of algorithms, which are based on mathematical formulas, that enable you to calculate pi with the desired accuracy and have more control over the process. The main disadvantage of this approach is that you have to write the code. However, when you have your own implementing of an algorithm, it’s easier to optimise it and thus make it faster.
The list of techniques that make it possible for you to calculate pi to arbitrary precision includes the following: Bailey–Borwein–Plouffe formula, the Bellard’s formula, the Borwein’s algorithm, the Chudnovsky algorithm, the FEE method, the Gauss–Legendre algorithm, the Leibniz formula, the Liu Hui’s algorithm for pi, the Viète’s formula, the Wallis product and the Zhao Youqin’s pi algorithm. Most of the aforementioned techniques calculate the summary of a…