MiniPi

Mini Pi approximations in JS (WIP)


Gregory-Leibniz series:

π = (4/1) - (4/3) + (4/5) - (4/7) + (4/9) - (4/11) + (4/13) - (4/15) …

(exponential and very inefficient: ~3h to get 6 decimals, ~18h to get 7 decimals, …)


Nilakantha series:

π = 3 + (4/(2*3*4)) - (4/(4*5*6)) + (4/(6*7*8)) - …

(exponential: computes 10+ decimals in a few seconds then it gets very long)


Machin formula:

π = 16*atan(1/5) - 4*atan(1/239)
with atan(x) = x - x^3/3 + x^5/5 - x^7/7…

which is equal to:

π = (16 * (1/5 ^ 1 / 1) - 4 * (1/239 ^ 1 / 1)) + (- 16 * (1/5 ^ 3 / 3) + 4 * (1/239 ^ 3 / 3)) + (16 * (1/5 ^ 5 / 5) - 4 * (1/239 ^ 5 / 5)) + (- 16 * (1/5 ^ 7 / 7) + 4 * (1/239 ^ 7 / 7)) …

(linear! computes ~1,4 digit per iteration, inspired by http://stephenbrooks.org/misc/jspi/decimal_animated.html)


Other “simple” formulae to test maybe: