Nth digit of PI

Randall Hopper aa8vb at yahoo.com
Wed Jul 5 07:18:27 EDT 2000


Jeff Massung:
 |Please, this interests me -- I've had differention equations, but that's as
 |far as I go. In theory, pi (and e) are infinite, but has that been proven
 |that there is not end to their decimals?

I don't know the mathematically-rigorous answer to your question.  But one
of the interesting things that you can show with a Fourier integral
(possibly other ways too) is that:

    Pi^2/8 = sum(n=1..inf, 1/(2n-1)^2)

You can see that the sum is 1/1 + 1/9 + 1/125 + ....  The terms get smaller
and smaller, which means making the decimal representation longer and
longer.  In the limit, the decimal representation is infinitely long
because the denominator is infinitely large.

Solving for pi:  multiplying by 8, you still have infinitely many digits,
and taking the square root, you still have infinitely many digits.  That's pi.

Randall

------------------------------------------------------------------------------
#!/usr/bin/env python
#
#  pi = sqrt( 8 * sum(n=1..inf, 1/(2n-1)^2) )
#    Not a realistic way to compute pi; convergence is hideously slow.
#    But with rational number arithmetic and lots of storage...
#

import math

ITERATIONS = 50000

sum = 0
for v in range(2*ITERATIONS-1,0,-2):
  sum = sum + 1/v**2.0

print "pi is approx %g (%d iterations)" % ( math.sqrt( sum * 8 ), ITERATIONS )




More information about the Python-list mailing list