value of pi and 22/7

Discussion in 'Python' started by Gerald Britton, Mar 20, 2011.

  1. Surely on track for the *slowest* way to compute pi in Python (or any
    language for that matter):

    math.sqrt( sum( pow(k,-2) for k in xrange(sys.maxint,0,-1) ) * 6. )

    Based on the Riemann zeta function:

    The sum of

    1/k^2 for k = 1:infinity

    converges to pi^2 / 6

    Depending on your horsepower and the size of sys.maxint on your
    machine, this may take a few *days* to run.

    Note: The sum in the Python expression above runs in reverse to
    minimize rounding errors.

    --
    Gerald Britton
     
    Gerald Britton, Mar 20, 2011
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Casey Hawthorne
    Replies:
    0
    Views:
    346
    Casey Hawthorne
    Oct 17, 2005
  2. kai
    Replies:
    1
    Views:
    287
    Larry Bates
    May 5, 2006
  3. CSINVA
    Replies:
    6
    Views:
    417
    Paul Delcogliano
    Nov 7, 2007
  4. ericnoonan
    Replies:
    0
    Views:
    365
    ericnoonan
    Dec 14, 2009
  5. Jack Bates
    Replies:
    0
    Views:
    288
    Jack Bates
    May 2, 2011
Loading...

Share This Page