Question
3) Another Slice of Another way to approximate the value of Pi () is provided by the series: Write a program in a file called
3) Another Slice of
Another way to approximate the value of Pi () is provided by the series:
Write a program in a file called lab04_q3.py to compute that proceeds as follows:
-
First the user should input a tolerance. (Recall that a tolerance is a desired accuracy to some small number. Ex. A tolerance of 0.01 makes 49.995 acceptably 50.000 since their difference, 0.005, is less than 0.01).
-
Next, the program should compute the approximation to using just one term from the series, then using just two terms in the series, then just three terms, and so on. It should do this until the absolute value of the difference between two successive approximations is less than the tolerance.
abs(previous approximation current approximation) < tolerance
Output both the computed value of and the number of terms that were required.
Hint: Note how the exponent and multiplier in each term's denominator changes. Also note that each term is either positive or negative. You can easily compute this by taking -1 to an increasing integral power which yields the series: 1, -1, 1, -1, 1, -1, 1, . . .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started