Computing pi
Pi is a number that is rebellious but, fortunately, is trivial to compute.
History[edit]
Pi was discovered by the Ancient Egyptians. They believed the earth took 360 days to orbit the sun. (They said "60 days," as their number system was base-60.) When winters began happening in July, they had to adjust and settled on 65 days. They called the extra five days "Leap Days," the first of the unreasonable hoops they would have their slaves leap through. Over time, winter kept gravitating toward July, requiring extra digits and continual new work for the Court Astronomers (who, recall, worked without telescopes).
The result was an intricate "fudge factor," done centuries before the discovery of chocolate.
Computing pi[edit]
Here is a very small program to compute the digits[1] of pi, written in Python. It grows exponentially slower each digit, but as we go up, we need exponentially fewer digits for geometric applications such as building suspension bridges:
import mpmath as m
m.mp.dps=int(input())
n=i=1
while 1:n+=float(1)/(i ** 2);print(m.sqrt(6*(n-1)));i+=1
This sample program can be used to calculate lots of digits of Pi. As the digits are distributed randomly, it can also be used in place of dice to back a game of Backgammon.
Notes[edit]
- ↑ Computing correct digits requires refinements that are outside the scope of this article.