Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions