sigma formula, issues with exponents or structure?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • orgnlmrwiggles
    New Member
    • Oct 2012
    • 2

    #1

    sigma formula, issues with exponents or structure?

    I have been working on this; It is a formula for estimating pi.

    My problem is that I am getting values no where near 3.14; all of my pi results are even coming out negative, and around -.000003, etc..

    Can you see where i made my mistake in the structure of the math?

    The formula is as follows:

    Sigma from K=0 > inf.
    2( -1^k ) * 3^[ (1/2) - k ]
    /
    2(k)+1


    Code:
     
    for k in range(0, 55, 5):
    pi = ( ( 2 * ( - 1 ** k ) ) * ( 3 ** ( ( 1 / 2 ) - k ) ) / ( 2 * k + 1 ) )
    print("After ", k, "terms, the approximation of pi is ", "%.3f" % pi)
    Last edited by orgnlmrwiggles; Oct 5 '12, 03:59 AM. Reason: Added that it is a sigma, series problem
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Maybe you have the wrong formula. This part always yields -2:
    Code:
    >>> (2 * (-1 ** 5))
    -2
    >>> (2 * (-1 ** 55))
    -2
    >>>
    Also, in an iterative series, it doesn't do much good to only remember the last calculation. Should the terms be additive, subtractive, multiplicative, combination? Start with an initial value and use augmented assignment operators (+=, -+, *=, etc.) to tabulate the result.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      1) To repeat bvdet, a sigma implies a cumulative sum, I don't know why you are only saving the last iteration.

      2) A sigma also requires a sequential range, I don't understand why you are using a step of five, that is no longer a sigma.

      3) The negative one needs to be within the power so you get positive numbers on an even iteration.

      The formula looks fine, I calculated it on the range 0 to 3 and it approached pi.
      Last edited by Rabbit; Oct 5 '12, 07:26 AM.

      Comment

      Working...