Archive

Posts Tagged ‘approximation’

First 15 digits of PI

September 27, 2010 2 comments

Look at this verse:

How I want a drink
alcoholic of course
After the heavy lectures
involving complex functions

Take the length of the words and you get the first 15 digits of PI. Here is the proof:

import sys
import math

s = """
How I want a drink
alcoholic of course
After the heavy lectures
involving complex functions
"""

print [len(w) for w in s.split()]
print math.pi

Output:

[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9]
3.14159265359   # the last digit is rounded here

Read more on PI at http://www.eveandersson.com/pi/.

And if you didn’t know, here is the PI song :)

 
Update (20110317)

You can approximate the value of PI with 355/113. The first 6 decimal places are the same. It’s quite easy to memorize it: visualize 113355, split into two (113 and 355), then do the division.

>>> import math
>>> math.pi
3.1415926535897931
>>> 355/113.
3.1415929203539825

Ref.: Kee Nethery at python-list.

Categories: python Tags: , ,
Design a site like this with WordPress.com
Get started