Question: % Problem 9 . 1 6 % The value of can be approximated with the Gregory - Leibniz series summation % pi / 4 =

% Problem 9.16
% The value of can be approximated with the Gregory-Leibniz series summation
% pi/4=1-1/3+1/5-1/7+1/9-1/11...
% or
% pi =4-4/3+4/5-4/7+4/9-4/11...
% 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 0.001.
% Set the maximum number of iterations to 3000. 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, my_pi.
% Follow these steps:
%1. Initialize 'total' to 0 for summing the series.
%2. Set the convergence criteria 'e' to 0.001.
%3. Use a for loop with a maximum of 3000 iterations to calculate the series.
%4. Within the loop, compute each term and add it to 'total'.
%5. Implement a midpoint break when the term's absolute value is less than 'e'.
%6. After the loop, assign the computed value to 'my_pi'.
% 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 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 Programming Questions!