logo Hurry, Grab up to 30% discount on the entire course
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Barbara ElseMathematics
(5/5)

923 Answers

Hire Me
expert
Mitchie SimaCriminology
(5/5)

940 Answers

Hire Me
expert
Eugene BaranowskiMathematics
(5/5)

881 Answers

Hire Me
expert
Nawaaj KhanEducation
(5/5)

860 Answers

Hire Me
Others
(5/5)

determine when π becomes greater than or equal to 3.14159265 and less than 3.14159266

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

CSC105 – Programming Logic

Lab04A:

Pi Approximation:  π can be computed using the following Nilakantha formula:

π  =  3 + 4/(2*3*4) - 4/(4*5*6) + 4/(6*7*8) - 4/(8*9*10) + 4/(10*11*12)…

or, where t = term, and i = iteration:

 

π  Value

=

3

3.1666666667

3.13333333333

3.14523809524

3.13968253968

Greater than or equal to 3.14 and less than 3.15

t

=

 

+

4/(2*3*4)

-

4/(4*5*6)

+

4/(6*7*8)

-

4/(8*9*10)

+

4/((2i)*(2*i+1)*(2*i+2))

i

=

0

1

2

3

4

i

                         

 

Notice the pattern in the denominators above, and the sign alternates to its opposite (positive to negative, negative to positive, etc.).  This can be coded as a “for” loop where you initialize the variable “sign” as a positive 1 before the loop body, and then multiply it by negative 1 inside the loop to change the sign for each iteration of the loop.  Here is a graph of the π values after the first four iterations:

Create a Python program called “PiApproximation.py” that displays the following π value for i = 200, i = 500, and i = 1000.  Then, determine exactly which iteration causes the value of π to reflect 3.14159265…  In other words, determine when π becomes greater than or equal to 3.14159265 and less than 3.14159266.  Print this out at the end of your output (after the values of π are printed out at iterations 200, 500, and 1000).  All output should be done using the format() function, and decimals should go to the 10th decimal place.

(5/5)
Attachments:

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme