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 -
-
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)
-
2 1984 bvdet 2,851
Expert Mod 2GB
Maybe you have the wrong formula. This part always yields -2: - >>> (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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
by: Patrick McGovern |
last post by:
Hi, quick question that's driving me nvts. how do i do exponential math in
C#?
--
Pat
|
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...
|
by: Mike |
last post by:
Hi,
I have three tables in the following structure (simplified):
Table 1: Containing the customers
-------------------------------------------------
create table Customers
(
int...
|
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
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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,...
| | |