Iterative approaches to calculating π in real time

Leibniz Formula for Pi

Leibniz formula for Pi (wikipedia)

The Leibniz formula for π was discovered by Gottfried Wilhelm Leibniz in the 17th century, around 1673. This formula represents π as an infinite series: π = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ...

Limitations: The Leibniz formula converges very slowly, meaning it requires a large number of terms to achieve a relatively small number of accurate decimal places of π.

Nilakantha Series

Nilakantha series for Pi (wikipedia)

Named after the Indian mathematician Nilakantha Somayaji in the 15th century. The Nilakantha series is an infinite series that converges to π. It starts with 3 and then continues: + 4/(2×3×4) - 4/(4×5×6) + 4/(6×7×8) - ...

Limitations: While it converges faster than the Leibniz formula, it still requires a significant number of iterations to achieve high precision.

Chudnovsky Algorithm for Pi

Chudnovsky algorithm for Pi (wikipedia)

The Chudnovsky algorithm was developed by brothers David and Gregory Chudnovsky in the late 20th century. This fast method for calculating π involves complex arithmetic and a quickly converging series, offering a highly efficient way to compute digits of π.

Limitations: Requires significant computational resources for high precision, making it complex for large-scale calculations.

Modifications for Web Implementation: I have implemented a simplified iterative version for this demonstration to showcase the algorithm's efficiency. In order to achieve an accurate value for pi I have added a 20% precision buffer.

How many digits of pi would you like to calculate? Please note that calculated values of pi using this method may be innaccurate below 100 digits and may take an extended period of time above 1000 digits. Enjoy!