How to calculate Pi

How to Calculate Pi, π, Simpson’s Rule
Nearly everyone knows that Pi or π is a peculiar number that is a little more than three. Most of those people know that the number has importance because it is the ratio of the distance around the perimeter (circumference) of a circle when compared to that circle’s diameter. It is what is called an irrational number, where no fraction can be written that equals it, and in fact, the decimal numbers needed to precisely define Pi would go on forever. So how is that number determined?
We will present two different methods of calculating it here. The first could be called the hard way, and it is the approach that ancient Greeks used 2300 years ago to first determine a value for Pi. The second is a much more sophisticated approach which relies both on Calculus and on something called Simpson’s Rule, to arrive at a far more precise value rather simply and easily.

Verder:

The Original Way of Determining Pi
First, let us define a circle that has what is called Unity diameter. That is, it has a Radius = 0.5 and a Diameter = 1.00.
We could INSCRIBE an equilateral triangle inside the circle, where the points/corners just touch the circle. We could carefully measure the length of the sides of that triangle, and would find that they are each slightly over 0.866 units long. With the triangle having three sides, the total perimeter of the triangle is therefore about 2.6 units. We can see that the distance around the circle is greater than this, in other words, Pi must be greater than 2.6. In the same way, we could draw an equilateral triangle which is larger, where the midpoints of the sides each exactly touch the circle, and we can measure the length of those sides to be around 1.732 units. Again, with three sides, we have a total perimeter of this triangle to be around 5.2 units, so we know the distance around the circle must be less than 5.2.
Now, if we do the same thing using squares instead, the larger number of sides more closely follows the shape of the circle and we get better results, indicating that Pi must be between 2.83 and 4.00. If we use five-sided pentagons instead, the result is better yet, Pi being between 2.94 and 3.63. By using six-sided hexagons, Pi is shown to be between 3.00 and 3.46.
For the ancient Greeks, this proceeded fairly well, but it took a lot of time and effort and it required really accurate measurements of the lengths of the sides of the regular polygons, and also really accurate drawings of those polygons so that they truly were Regular (all equal sided). However, the process was continued (skipping many numbers of sides) up to 120 sides. If you think about it, a 120-sided inscribed polygon would clearly very closely resemble the shape of the circle, and would therefore closely indicate the value of Pi. In fact, by using 120-sided polygons, we can determine that Pi must be between 3.1412 and 3.1423, decently close to the 3.1416 that we all know. In fact, if you average the two values (based on lower limit and upper limit) you get 3.1418. a value that is quite close!
However, that value is not close enough for modern Engineering requirements! Which is why the advanced approach presented below is now considered far better. However, here is a chart of the (measured and calculated) values for various numbers of sides for the polygons. Note that if we do this for 2000-sided polygons, the value becomes quite close. However, the process of doing that measurement is extremely difficult for such short polygon sides, when the measured dimension must be to an accuracy of better than one-part-in-a-million!
Number
of sides inside
one side inside
total outside
one side outside
total average
in/out
3 0.866025 2.598076 1.732051 5.196152 3.897114
4 0.707107 2.828427 1.000000 4.000000 3.414214
5 0.587785 2.938926 0.726543 3.632713 3.285820
6 0.500000 3.000000 0.577350 3.464102 3.232051
7 0.433884 3.037186 0.481575 3.371022 3.204104
8 0.382683 3.061467 0.414214 3.313709 3.187588
9 0.342020 3.078181 0.363970 3.275732 3.176957
10 0.309017 3.090170 0.324920 3.249197 3.169683
11 0.281733 3.099058 0.293626 3.229891 3.164475
12 0.258819 3.105829 0.267949 3.215390 3.160609
13 0.239316 3.111104 0.246478 3.204212 3.157658
14 0.222521 3.115293 0.228243 3.195409 3.155351
15 0.207912 3.118675 0.212557 3.188348 3.153512
16 0.195090 3.121445 0.198912 3.182598 3.152021
17 0.183750 3.123742 0.186932 3.177851 3.150796
18 0.173648 3.125667 0.176327 3.173886 3.149776
19 0.164595 3.127297 0.166870 3.170539 3.148918
20 0.156434 3.128689 0.158384 3.167689 3.148189
120 0.026177 3.141234 0.026186 3.142311 3.141772
480 0.006545 3.141570 0.006545 3.141637 3.141604
2000 0.001571 3.141591 0.001571 3.141595 3.141593

The Improved Way of Determining Pi
This will be kept fairly painless! Actually, you do not need to know any Calculus, or even anything beyond simple adding, multiplying and dividing to do this! These next few paragraphs just explain the basis of why this works, which is because of some results in Calculus.
We first need to note that the definition of Pi is the diameter times Pi giving the circumference of any circle. That means that the circumference is equal to 2 * Pi, so half a circle or 180 degrees equals Pi (usually said to be Pi radians).
It turns out to be fairly easily provable in Calculus that the Derivative of the Inverse Tangent (a trigonometry term) is equal to 1/(1 + X2). Since both the Tangent and its Derivative are continuous functions (except at specific points, which we will avoid), that means that the ANTI-Derivative of 1/(1 + X2) is the Inverse Tangent. For a continuous function, the Anti-Derivative is the same as the Integral, so this means that the Integral of 1/(1 + X2) is equal to the Inverse Tangent (over a given interval of angles).
We can select a specific range of angles, and for simplicity we select from zero to the angle which has a tangent of exactly 1, which is the angle that we often call 45 degrees. So if we can just evaluate that quantity 1/(1 + X2) over the range of X equals 0 to 1, and add it all up (as a Calculus Integral does), we would then have a result that equalled the difference which is just the angle between the two angles. In Trigonometry, the circumference of a circle is given as 2 * Pi * R, where Pi therefore represents 180 degrees. Therefore our 45 degree range is just Pi/4, exactly.
Therefore, by evaluating the Integral of our 1/(1 + X2) over the range of 0 to 1, we would get a result that was exactly equal to Pi/4. We’re getting somewhere!
There is a well proven rule in mathematics called Simpson’s Rule. It is actually an approximation, but a really good one, which is essentially based on the fact that if any three points of a curve are known, a unique parabolic curve can be drawn which passes through them, and so the simple quadratic formula for a parabola then gives a very good estimate for the curve in that section. In any case, Simpson’s Rule is fairly simple, when the points on the curve are equally spaced along a coordinate, and that there are an even number of intervals between those points. We will use the simple example of four intervals, or 5 data points here.
Our whole range is from 0 to 1, so our interval must be exactly 1/4, so we have values for X of 0, 1/4, 1/2, 3/4, and 1. We can easily calculate our 1/(1 + X2) for each of these values, to get 1, 16/17, 4/5, 16/25, and 1/2. Simpson’s Rule is actually very simple, where these various terms get multiplied by either 1, 2, or 4, and added together. I am going to make you find some textbook for the exact pattern, but it is really extremely simple. If presented here, it might distract from the central point! (The following tables do indicate those multipliers)
We can present our data here in a small table:
Number of divisions = 4
value of X Quantity
Calculated
1/(1 + X2) . Running Total
of multipled
Quantities
0.00 1.0000000 1 1.0000000
0.25 0.9411765 4 4.7647059
0.50 0.8000000 2 6.3647059
0.75 0.6400000 4 8.9247059
1.00 0.5000000 1 9.4247059
According to Simpson’s Rule we now need to divide this by 3 and multiply by the size of our intervals (1/4), in other words, in this case, dividing by 12. We then get a result of 0.7853921569.
This value is then equal to the number of radians in 45 degrees. To get the number of radians in 180 degrees, in other words, Pi, we just multiply by four. We then get 3.1415686275
Given how simple this was to do, easily done with pencil and paper, it is pretty impressive that we get a result that is surprisingly precise!
So now we decide to use six intervals instead of four!
Number of divisions = 6
value of X Quantity
Calculated
1/(1 + X2) . Running Total
of multipled
Quantities
0 1.0000000 1 1.0000000
1/6 0.9729730 4 4.8918919
1/3 0.9000000 2 6.6918919
1/2 0.8000000 4 9.8918919
2/3 0.6923077 2 11.2765073
5/6 0.5901639 4 13.6371630
1 0.5000000 1 14.1371630
We must now divide this by 3 and multiply by 1/6, or actually, divide by 18, to get: 0.7853979452
Multiplying this by four give 3.1415917809 as even a much better value for Pi.
It seems important to again note that this is a simple pencil and paper calculation that only involves simple addition, multiplication and division, and no exotic math stuff! Impressive, huh?
Well, you are free to invest maybe an hour in doing this calculation for 26 intervals. You will get a result of 0.7853981634 and then 3.1415926535 for the value of Pi, which is accurate to all ten of these decimal points!

So, just in case you had thought that the original ancient Greek approach was still used, with polygons having billions of sides, in determining the extremely accurate values for Pi (sometimes given to 100 or one million decimals), now you know how it is actually done! Setting up a computer to do these simple additions, multiplications and divisions is pretty easy, and the only limitation then is the accuracy of the values of the numbers used in the computer. If you use a computer system that has 40 significant digits, even YOU could now quickly calculate Pi to 40 decimals!

Yet another modern way!
It turns out that there is a way to do this without having to rely on Simpson’s Rule. There is another Calculus proof that the quantity the Integral of 1/(1 + X2), or the Inverse Tangent of X, we used above can be expressed as an alternating infinite series, as:
X – X3/3 + X5/5 – X7/7 + X9/9 …
Since our values of X are zero and one, this simplifies. When X = 0 it is obvious that this is a sum of a lot of zeroes, or zero. For X = 1, this is just:
1 – 1/3 + 1/5 – 1/7 + 1/9 …
So the difference, the number we want that is Pi/4 is obviously just this last infinite series total. Sounds easy, huh? It is, except that you have to include a LOT of terms to get a very accurate value for Pi!
If you do this for a sum of the terms up to 1/41 (20 terms), you get a value for Pi of 3.0961615.
If you do this for a sum of the terms up to 1/4001 (2000 terms), you get a value for Pi of 3.1410931.
If you do this for a sum of the terms up to 1/400001 (200,000 terms), you get a value for Pi of 3.1415876.
If you do this for a sum of the terms up to 1/4000001 (2,000,000 terms), you get a value for Pi of 3.14159215.
If you do this for a sum of the terms up to 1/40000001 (20,000,000 terms), you get a value for Pi of 3.14159260.
That would be a LOT of additions and subtractions to get a value for Pi that still is not very impressive! We noted above that the actual value for Pi to ten decimals is 3.1415926535, so with this other method, our 20 million additions and subtractions still only get a precision to around 7 correct decimals. Not nearly as good as the Simpson’s Rule method above, even though it initially looks very attractive!
But we are showing that there are many ways to skin a cat! (figuratively speaking, of course!)

This presentation was first placed on the Internet in November 2006.
ImageThis page – – How to Calculate Pi, π, Simpson’s Rule – – is at http://mb-soft.com/public3/pi.html
This subject presentation was last updated on 01/12/2011 03:40:26

Link to the Index of these Public Service Pages
Image( http://mb-soft.com/index.html )