Question: % Problem 9 . 1 6 % The value of can be approximated with the Gregory - Leibniz series summation % pi / 4 =
Problem
The value of can be approximated with the GregoryLeibniz series summation
pi
or
pi
The series converges very slowly. Calculate pi using a midpoint break loop implemented with a for loop.
Determine convergence by comparing successive values of the summation as you add additional terms
until the absolute value of the difference between successive sums is less than a convergence criteria, e of
Set the maximum number of iterations to Hint: Calculate successive terms in the series before you add them to the running total.
Since the new term is the difference between the successive sums you can use this value to compare to the convergence criteria.
Using this strategy it is not necessary to store both the current and former values of the successive sums.
Name your approximate value of pi mypi
Follow these steps:
Initialize 'total' to for summing the series.
Set the convergence criteria e to
Use a for loop with a maximum of iterations to calculate the series.
Within the loop, compute each term and add it to 'total'.
Implement a midpoint break when the term's absolute value is less than e
After the loop, assign the computed value to mypi
Use'k' as the counter in the for loop.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
