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.


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.

Text Font Face
.
Text Size
.
Background
Color
.
(for printing)
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!

Public Service
Categories
Becoming Self-Sufficient

Environmental Subjects

Scientific Subjects

Advanced Physics

Social Subjects

Religious Subjects

Public Services Home Page

Main Menu
E-mail

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.8660252.5980761.7320515.1961523.897114
4 0.7071072.8284271.0000004.0000003.414214
5 0.5877852.9389260.7265433.6327133.285820
6 0.5000003.0000000.5773503.4641023.232051
7 0.4338843.0371860.4815753.3710223.204104
8 0.3826833.0614670.4142143.3137093.187588
9 0.3420203.0781810.3639703.2757323.176957
10 0.3090173.0901700.3249203.2491973.169683
11 0.2817333.0990580.2936263.2298913.164475
12 0.2588193.1058290.2679493.2153903.160609
13 0.2393163.1111040.2464783.2042123.157658
14 0.2225213.1152930.2282433.1954093.155351
15 0.2079123.1186750.2125573.1883483.153512
16 0.1950903.1214450.1989123.1825983.152021
17 0.1837503.1237420.1869323.1778513.150796
18 0.1736483.1256670.1763273.1738863.149776
19 0.1645953.1272970.1668703.1705393.148918
20 0.1564343.1286890.1583843.1676893.148189
120 0.0261773.1412340.0261863.1423113.141772
480 0.0065453.1415700.0065453.1416373.141604
2000 0.0015713.1415910.0015713.1415953.141593


(You are aware that the accurate known value is 3.1415926535, so this process would get pretty close.

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 equaled 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 X = 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 now 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 XQuantity
Calculated
1/(1 + X2)
.Running Total
of multiplied
Quantities
0.00 1.00000001 1.0000000
0.25 0.94117654 4.7647059
0.50 0.80000002 6.3647059
0.75 0.64000004 8.9247059
1.00 0.50000001 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 XQuantity
Calculated
1/(1 + X2)
.Running Total
of multiplied
Quantities
0 1.00000001 1.0000000
1/6 0.97297304 4.8918919
1/3 0.90000002 6.6918919
1/2 0.80000004 9.8918919
2/3 0.6923077211.2765073
5/6 0.5901639413.6371630
1 0.5000000114.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 - 1/11 + 1/13 ...

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 good but 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.

This page - - - - is at
This subject presentation was last updated on - -



Link to the Home Page

http://mb-soft.com/index.html



Link to the Public Service Science Projects Index

http://mb-soft.com/public/othersci.html



E-mail to: Public4@mb-soft.com

C Johnson, Theoretical Physicist, Physics Degree from Univ of Chicago