There are several approximations to calculate the value of p

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.

Solution

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

 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 i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site