def arccot(x, dig):
powx=total=10**(11+dig)/x
n=3
sign=term=-1
while term:
powx /= x*x
term=powx / n
total+=sign*term
n+=2
sign=-sign
return total/pow(10,10)
def pi(dig):
pi=4 * (4*arccot(5, dig) - arccot(239, dig)) #Machin's Formula
return pi/10
print pi(100000)
powx=total=10**(11+dig)/x
n=3
sign=term=-1
while term:
powx /= x*x
term=powx / n
total+=sign*term
n+=2
sign=-sign
return total/pow(10,10)
def pi(dig):
pi=4 * (4*arccot(5, dig) - arccot(239, dig)) #Machin's Formula
return pi/10
print pi(100000)
No comments:
Post a Comment