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

Homework assignment 06-Feb-2018 COMPUTE P Calculating Pi (a) using infinite seri

ID: 2261649 • Letter: H

Question

Homework assignment 06-Feb-2018 COMPUTE P Calculating Pi (a) using infinite series Mathematicians eventually discovered that there are in fact exact formulas for calculating P (T). The only catch is that each formula requires you to do something an infinite number of times. (Which makes sense given that the digits of Pi (m) go on forever.) One of the amazing things which interests people about Pi(m) is that there isn't just one formula, but a large number of different ones for people to study One of the most well-known and beautiful ways to calculate Pl (m) is to use the Gregory-Leibniz Series: If you continued this pattern forever you would be able to calculate a4T14 exactly and then just multiply it by 4 in order to get . If however you start to add up the first few terms, you will begin to get an approximation for Pi (). The problem with the series above is that you need to add up a lot of terms in order to get an accurate approximation of Pi (m) You need to add up more than 300 terms in order to produce Pi (m) accurate to two decimal places 4-1--+--11 +-... er series which converges more quickly is the Nilakantha Series which was developed in the ntury. Converges more quickly means that you need to work out fewer terms for your answer Anoth to become closer to Pi (m). Nilakantha Series = 3+2+3+4 4+5+6+6+7.8 8.9-10 Assignment Compute Pl using the Nilakantha Series, asking the user for the number of terms to compute. IE 300 iterations Due Tuesday 13-Feb-2018 Points 20

Explanation / Answer

%%% Matlab code %%%

clc;
clear all;
close all;
format compact
n=input('Enter the number of term, n = ');
sum=3;
for i=1:n
sum=sum+(-1)^(i+1)*4/((2*i)*(2*i+1)*(2*i+2));
end
fprintf('Approximate value of pi by adding %d term = %f ',n,sum);

OUTPUT:

Enter the number of term, n = 5
Approximate value of pi by adding 5 term = 3.142713