Calculating PI using trigonometric iterations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Calculating PI using trigonometric iterations
# FB36 - 20130825
import math
x = 1.0
y = 1.0
z = 1.0
w = 1.0
v = 1.0
u = 1.0
for i in range(30):
x = math.sin(x) + x
y = math.cos(y) + y
z = math.cos(z) + math.sin(z) + z
w = math.cos(w) - math.sin(w) + w
v = math.cos(v) * math.sin(v) + v
u = math.cos(u) / math.sin(u) + u
print i
print x, y * 2.0, z * 4.0 / 3.0, w * 4.0, v * 2.0, u * 2.0
print
|
Another version: