(02-09-2018 02:01 AM)Mike (Stgt) Wrote: (02-08-2018 11:48 PM)Gerson W. Barbosa Wrote: Madhava-Leibniz is interesting, [...]
\[{\displaystyle {\frac {\pi }{4}}=1-{\frac {1}{3}}+{\frac {1}{5}}-{\frac {1}{7}}+\cdots +{\frac {(-1)^{n}}{2n+1}}+\cdots } \]
Seems I confused by so many formulas. What you quote is the Madhava-Leibniz formula. In contrast what I use is a more rapidly converging series also from Madhava.
Code:
s = 1
n = 1
DO m = 3 by 2 UNTIL m = m + n
n = n / -3
s = s + n / m
end
Pi = 2 * s * Sqrt(3)
This needs about 2 iterations per correct digit of Pi. In my list I marked it falsely with 'Madhava-Leibniz'.
To reduce the loop overhead I merged two steps (what results in a remarkable gain on my system):
Code:
s = 1
n = 1
DO m = 3 by 4 UNTIL m = m + n
n = n / 9
s = s + n / (m + 2) - 3 * n / m
end
Pi = 2 * s * Sqrt(3)
BTW, instead of tantalizing your real machine for 6 hrs, I suggest a well known emulator of it. Recently I set it to authentic speed for some reason, and I am so glad I can switch it back to full speed. Could help in this case too.
Ciao.....Mike
You're still limited to the precision of a variable (Pi), right? How would you go beyond 12 or 13 digits? If you can't, why go to all that trouble to get a number you can get with a single command. That's not a rhetorical question, I'd really like to know.