Pete, that should work but you need to perform all calculations to digits accuracy
there's a quartic version of the Gauss–Legendre algorithm for Pi, that is the accuracy quadruples on each iteration, but I find that's a bit slower https://en.wikipedia.org/wiki/Approximat...algorithms
the quartic version would be something like the following
there's a quartic version of the Gauss–Legendre algorithm for Pi, that is the accuracy quadruples on each iteration, but I find that's a bit slower https://en.wikipedia.org/wiki/Approximat...algorithms
the quartic version would be something like the following
Code: (Select All)
y=2 : y=sqr(y)
a=6 : a=a-4*y : y=y-1
p=2
for k=0 to int(log(NUMBER_OF_DIGITS)*0.72134752044448) '1/ln(4)
y=y*y : y=y*y 'y^4
y=1-y : y=sqr(y) : y=sqr(y)
y=(1-y)/(1+y)
p=p*4
yk=y+1
yk=yk*yk : yk=yk*yk
a=a*yk-p*y*(1+y+y*y)
next
pie = 1/a
print pie