There are several approximations to calculate the value of pi. One of the smarte
ID: 3935745 • Letter: T
Question
There are several approximations to calculate the value of pi. One of the smartest one among these is Archimedes' method. The idea behind the method is that if we use a polygon with n sides and assume that the area of the polygon is equal to the area of the circle, we can approximate the value of pi. Moreover, if we increase the number of the sides of the polygon, result will be more close to the circle. Using this information, write a MATALAB scriptr, named "Ql.m'', to calculate the value of pi using a for loop with i=1, 2, 3, 4 for n=6, n=30, n=80 and n=200 and store these values in an array. Use format long command, compare the results and make comments.Explanation / Answer
Following is the required matlab code. As N increases, value of pi comes more closer to the actual value
%Assuming circle is of R = 1
NsAre = [ 6 30 80 200 ];
pis = [];
for i=1:4
N = NsAre(1,i);
area = N*0.5*sin( 2*pi/N );
pis = [ pis area ];
end
format long
pis
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.