PYTHON PROGRAMMING : Answer must be python code. You must code a program that approximates the number pi by summing a series of numbers. Mathematically the number pi is equal to the following infinite sum: pi = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ... Notice the alternation of signs from one term to another of the series (positive, negative, positive, ...) Moreover, notice that the divisors are the odd numbers. We would like to check with a program that the sum converges to pi. Here is the specification of the program: The program must sum the terms one at a time and display the sum whenever the number of terms used is a power of 10 (so at 1 term, 10 terms, 100 terms, 1000 terms, etc). On the other hand the program must stop as soon as the error (the absolute value of the difference between the sum and pi) is less than 5e-6 and indicate how many terms there are in the sum and the value of the sum. As a precaution, in case the sum does not converge fast enough, your program should stop when 10**6 terms are added and display a message indicating that the error is not less than 5e-6 after the first 10**6 terms are added. Note that the best floating point approximation of pi is found in math.pi. You must use print for all displays. You must make the display exactly in the following format: at 1 term the sum is equal to xxxxxxxxx at 10 terms the sum is equal to xxxxxxxxx at 100 terms the sum is equal to xxxxxxxxx at 1000 terms the sum is equal to xxxxxxxxx at 10000 terms the sum is equal to xxxxxxxxx the sum reaches the tolerable error of xxxxxxxxx at xxxxxxxxx terms the sum is equal to xxxxxxxxx where xxxxxxxxx is a number. If the tolerable error is not reached, then the second last line must be in this format: the sum did not reach the tolerable error from xxxxxxxxx to xxxxxxxxx terms. Your program must use significant identifiers in ASCII camelCase, it must be well indented, without too long lines, and it must be well commented. In short, as if your code will be used by another programmer in the future. Comments should include: your name and the date at the beginning of the code a brief explanation of the purpose of the code an explanation of each variable declared an explanation of how the code works (its logic) It must be easy to modify the error you are looking for. The very first statement of your program must therefore be a variable declaration. This variable must contain the floating number corresponding to the error sought by your program. When you submit, the value 5e-6 must be assigned to this variable, but it must be possible to modify it. Be sure to choose a meaningful identifier for it.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

PYTHON PROGRAMMING : Answer must be python code.

You must code a program that approximates the number pi by summing a series of numbers. Mathematically the number pi is equal to the following infinite sum:

pi = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ...

Notice the alternation of signs from one term to another of the series (positive, negative, positive, ...) Moreover, notice that the divisors are the odd numbers.

We would like to check with a program that the sum converges to pi. Here is the specification of the program:

The program must sum the terms one at a time and display the sum whenever the number of terms used is a power of 10 (so at 1 term, 10 terms, 100 terms, 1000 terms, etc). On the other hand the program must stop as soon as the error (the absolute value of the difference between the sum and pi) is less than 5e-6 and indicate how many terms there are in the sum and the value of the sum. As a precaution, in case the sum does not converge fast enough, your program should stop when 10**6 terms are added and display a message indicating that the error is not less than 5e-6 after the first 10**6 terms are added. Note that the best floating point approximation of pi is found in math.pi.

You must use print for all displays. You must make the display exactly in the following format:

at 1 term the sum is equal to xxxxxxxxx
at 10 terms the sum is equal to xxxxxxxxx
at 100 terms the sum is equal to xxxxxxxxx
at 1000 terms the sum is equal to xxxxxxxxx
at 10000 terms the sum is equal to xxxxxxxxx
the sum reaches the tolerable error of xxxxxxxxx at xxxxxxxxx terms
the sum is equal to xxxxxxxxx
where xxxxxxxxx is a number. If the tolerable error is not reached, then the second last line must be in this format:

the sum did not reach the tolerable error from xxxxxxxxx to xxxxxxxxx terms.
Your program must use significant identifiers in ASCII camelCase, it must be well indented, without too long lines, and it must be well commented. In short, as if your code will be used by another programmer in the future. Comments should include:

your name and the date at the beginning of the code
a brief explanation of the purpose of the code
an explanation of each variable declared
an explanation of how the code works (its logic)
It must be easy to modify the error you are looking for. The very first statement of your program must therefore be a variable declaration. This variable must contain the floating number corresponding to the error sought by your program. When you submit, the value 5e-6 must be assigned to this variable, but it must be possible to modify it. Be sure to choose a meaningful identifier for it.

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY