Created
March 17, 2016 05:03
-
-
Save rishi93/bcfe1c964a0e6bfb50c8 to your computer and use it in GitHub Desktop.
Digits of Pi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Calculating Pi, William Shank's method using Machin's formula | |
def arctan(x): | |
result = 0 | |
for i in range(1,11): | |
t = 2*i - 1 | |
if (i % 2 == 0): | |
result = result - (x**t)/t | |
else: | |
result = result + (x**t)/t | |
return result | |
pie = 16*arctan(1/5) - 4*arctan(1/239) | |
print(pie) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment