Post 2
Something I forgot about initial setup: U.S. users -- be sure to change the default keyboard from UK to US. Otherwise, lots of luck finding important special characters.
Here's my Python program (copy/try it if you wish):
===================
# Compute Pi to 10,000 places
# recoded using the algorithm from "ABC Programmers Handbook", Geurts, et al
def arccot(x, unity):
sum = xpower = unity // x
n = 3
sign = -1
while 1:
xpower = xpower // (x*x)
term = xpower // n
if not term:
break
sum += sign * term
sign = -sign
n += 2
return sum
def pi(digits):
unity = 10**(digits + 10)
pi = 4 * (4*arccot(5, unity) - arccot(239, unity))
return pi // 10**10
ans = str(pi(10000))
ans = ans[0:1]+'.'+ans[1:] # insert decimal point
print ans
=====================
BTW: this takes 4 seconds on the Pi and .6 second on my iMac. Same answer, though.
What I'd like to do with the Pi: (sounds like a 3rd-graders essay)
My grand-daughter & husband have a vegetable farm. They have built a cold storage building and need to trick a window AC unit into keeping it cooled to 40 degrees F. They also could use other automation aids: a) alarm on the lock, motion detector, soil moisture reading, plus lots more. I'd like them to be able to control the Pi via a local WAN by an iPhone. This will be a challenge!
More as I progress.
Dick Haight
No comments:
Post a Comment