Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The mathematical constant Pi is an irrational number with value approximately 3.

ID: 3916155 • Letter: T

Question

The mathematical constant Pi is an irrational number with value approximately 3.1415928... The precise value of this constant can be obtained from the following infinite sum: Pi-8 +8/32 +8/52 +8/72 +8/92 + (P11s of course just the square root of this value.) Although we cannot compute the entire infinite series, we get a good approximation of the value of Pi by computing the beginning of such a sum. Write a function approxPIsquared() that takes as input float error and approximates constant Pi to within error by computing the above sum, term by term, until the difference between the new and the previous sum is less than error. The function should return the new sum x>> approxPIsquared(0.0001) 9.855519952254232 >>> approxPIsquared (0.00000001) 9.869462988376474

Explanation / Answer

Function that takes as input float error and approximates constant Pi2.

def approxPIsquared(error):
prev_PI = 8
new_PI = 8 + 8/3**2
i = 5
dif = new_PI-prev_PI
while error<=dif:
prev_PI = new_PI
new_PI += 8/i**2
dif = new_PI-prev_PI
i+=2
return new_PI

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote