Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 Re: Coder's Corner » Python! » 2009-06-23 01:28:56

ok well that makes sense.

#2 Re: Coder's Corner » Python! » 2009-06-22 18:33:15

It was the easiest the use though. Im not sure how to translate this http://en.wikipedia.org/wiki/Bellard%27s_formula
To me it just looks like this, it's obviously not right.

n = 0
pi = 1/2^6
while True:
        a= -1*n/2^(10*n)*(-2^5/4*(n+1)-1/4*(n+3)+2^8/10*(n+1)-2^6/10*(n+3)-2^2/10*(n+5)-2^2/10*(n+7)+1/10*(n+9))/10*(n+9))
        pi+=a
        n+=1
        print pi

#3 Re: Coder's Corner » Python! » 2009-06-21 01:59:35

Hey im probably a little old but i wanna learn more math and i've a passing familiarity with python.
I gave it a shot and it's really slow, can anyone else resolve pi faster?

def seq(n):
    n = n+2
    return [n, n+2]

def findpi():
    pi = 0
    k = -1
    while True:
        i = seq(k)
        a = (4.0/i[0])-(4.0/i[1])
        pi = pi + a
        k= k + 4
        print pi
findpi()

Im pretty sure 3.0 is "the future", aka an experimental version. All the interesing modules I've found are for 2.5+

added more simple

Board footer

Powered by FluxBB