Share

Calculating Pi

File Release Notes and Changelog

Release Name: First Release

Notes: This program calculates the value of pi. A regular polygon having 'n' number of sides is inscribed within a circle of known radius and another regular polygon with the same number of sides is circumscribed around thecircle. As the value of 'n' is increased, the average value of the perimeters of the two regular polygons approach the circumference of the circle. The average when divided by the diameter of the circle gives the approximate value of Pi.


Changes: For greater accuracy, 'n' has been taken as power of 2. If we join the centre of any one of the two polygons to two adjacent vertices of the same polygon, the angle subtended between the two straight lines must be known if we are to calculate the perimeter. For a 'n' sided polygon (where n=2^r), this angle is (360/2^r)degrees=(45/2^(r-3))degrees. Since the value of cos 45 degree can be determined without using pi, the cosine of this angle can also be deduced by repeatedly using the formula cos (x/2)=sqrt(((cos x) +1)/2).