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

Problem #3 Pi (T) is the ratio of a circle\'s circumference to its diameter. Man

ID: 3028368 • Letter: P

Question

Problem #3 Pi (T) is the ratio of a circle's circumference to its diameter. Many mathematicians have found ways to approximate TT. For example, Machin's formula is: TT 4arctan. arctan 239 Leibniz found that T can be approximated by: 4 4 4 4 4 4 1 5 79 11 This is called a sum of a series. For example, there are six terms shown in the above series. The first term is 4 the second term is -4/3, the third term and so forth. Notice the alternating signs. Write a menu-driven program with the following options that the user can pick. Print the value of MATLAB's built-in pi constant. Print the result from Machin's formula. (Write this as a separate function. The output argument is the calculated result Print the approximation using Leibniz' formula, allowing the user to specify how many terms to use. (Write this as a separate function. The input argument is the number of terms. The output argument is the calculated result.) Print the approximation using Leibniz' formula, looping until the error between the approximation and the MATLAB pi value is below a user-specified tolerance, i.e., stop once lpi approx pil s etol. (Write this as a separate function. The input argument is the error tolerance value. The output argument is the calculated result.) Exit the program.

Explanation / Answer

clc;
clear all;
close all;
x=pi;
%%%% Calculating using Machin's Formula
x1=4*( 4*atan(1/5)-atan(1/239));

%%%%%

% % % Leibinz formula

n=input('Enter the number of terms u want in the expansion');
su=0;
for k=1:n
su=su+4*(-1)^(k+1)/(2*k-1);
end

x2=su;

% % % Based on the tolerance
n=input('Enter the amount of tolerence u want in the error');
su1=0;
%%% Initially consider only 5 terms


for k=1:1000
su1=su1+4*(-1)^(k+1)/(2*k-1);
if ( k>6)
if (abs(pi-su1)<=n)
break;
end
end
end

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