Question: Using python, The 17th century German mathematician Gottfried Leibniz developed the following method to approximate the value of pi: As you can see, if we
Using python,
The 17th century German mathematician Gottfried Leibniz developed the following method to approximate the value of pi:
As you can see, if we enumerate the terms in the sum starting from zero (i.e. 1 is the zeroth term, k = 0; next -1/3 is the first term, k=1, etc) then subsequent terms in the sum are alternating signs and their absolute magnitudes are equal to 1/(2*k+1) for the corresponding k = 0, 1, 2, ... Or you can just observe that every time we move from one term to the next, the denominator always increases by 2. Does not matter which particular way you decide to track and code the terms in the sum for as long as your summation is correct.
Write a program that asks user to enter the number of terms in the Leibniz formula to sum up, performs the summation and prints out the obtained approximation for pi. Experiment a little bit, try different inputs. Leibniz formula is not very practical as the above series converges very slowly and one needs to sum up huge number of terms to get good accuracy. Observe what you get when you sum up 100, 1000, 10,000, 100,000 terms (if your computer can handle it).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
