473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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


Expand|Select|Wrap|Line Numbers
  1.  
  2. for k in range(0, 55, 5):
  3. pi = ( ( 2 * ( - 1 ** k ) ) * ( 3 ** ( ( 1 / 2 ) - k ) ) / ( 2 * k + 1 ) )
  4. print("After ", k, "terms, the approximation of pi is ", "%.3f" % pi)
  5.  
Oct 5 '12 #1
2 1984
bvdet
2,851 Expert Mod 2GB
Maybe you have the wrong formula. This part always yields -2:
Expand|Select|Wrap|Line Numbers
  1. >>> (2 * (-1 ** 5))
  2. -2
  3. >>> (2 * (-1 ** 55))
  4. -2
  5. >>> 
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.
Oct 5 '12 #2
Rabbit
12,516 Expert Mod 8TB
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.
Oct 5 '12 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Matt Fuerst | last post by:
Greetings all, I'm having an issue with my Web application. It's deployed using Crystal Reports 8.0 Developer edition. I have an RPT file with a relatively large number of formulas (30+). I...
2
by: Alex Vinokur | last post by:
Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any numbers and words? -- Alex Vinokur mailto:alexvn@connect.to...
2
by: Stefan L | last post by:
Hi NG, I have the following problem: Is there a way to use exponents in C#-code without converting to a double and then use System.Math? I have to convert VB-Code to C# and in VB its easy...
6
by: Patrick McGovern | last post by:
Hi, quick question that's driving me nvts. how do i do exponential math in C#? -- Pat
4
by: sal | last post by:
Greets, All Converting array formula to work with datatables/dataset tia sal I finally completed a formula I was working on, see working code below. I would like to change this code so it...
3
by: Mike | last post by:
Hi, I have three tables in the following structure (simplified): Table 1: Containing the customers ------------------------------------------------- create table Customers ( int...
8
by: grahamhow424 | last post by:
Hi I am trying to figure out how to duplicate a, financial, calculation that uses the caret, Exponentiation. Here's the formula... A = 0.0755 B = 34 C = 50000
1
by: JHaworth | last post by:
Hi, Please could someone point me in the right direction with a formula I am trying to create which will enable me to calculate a Net IRR for a series of data? My Problem: •My formula in...
30
by: Barry L. Bond | last post by:
Greetings! I just got a new Peet Brothers Ultimeter 2100 Weather Station. This new one has a way to display the heat index, if you press the "dew point" key twice. Being aware of all the...
2
jkmyoung
by: jkmyoung | last post by:
Calculating Large Exponents Background: This is a quick article as to how to calculate the exponents of large numbers quickly and efficiently. Starting with a basic multiplication algorithm, it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.