Question: Pi is an irrational number whose first digits are: 3.1415928. The precise value of pi is equal to the infinite sum: pi = 4/1 -

Pi is an irrational number whose first digits are: 3.1415928. The precise value of pi is equal to the infinite sum: pi = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ... You can compute better and better approximations of pi by computing more terms of the series. Write function approxPi(deltaValue) that computes and returns an approximation of pi. Use a while loop (not a for loop). Each iteration should update the pi approximation by including one additional term from the series. The loop should terminate when the difference between the previous iteration's approximation and the new iteration's approximation is less than deltaValue. For example

>>> approxPi(.01) 3.1465677471829556 >>> approxPi(.005) 3.144086415298761 >>> approxPi(.00001) 3.141597653564762

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!