Monday, November 23, 2009

I'm a Geek

I'm planning to go back to school in January to take prerequisite classes enabling me to apply to engineering programs. In order to save time and money, I'm trying to avoid taking first-year calculus again, so I've been re-teaching myself math. This time around, I've been finding myself fascinated with certain things - why is the Pythagorean theorem true? How did people figure out pi?

In reading about pi, I read about a formula to calculate it used in some of the earlier computer approximations. Pi is the ratio of a circle's circumference to its diameter.

C=πd

A circle can be thought of as a decayed polygon. As the number of sides of the polygon approaches infinity, the polygon approaches a circle and its perimeter approaches C. So the problem of calculating pi can be solved by calculating the perimeter of a polygon with lots and lots of sides, until either pi stops changing (this never happens - it's an irrational number) or one runs out of computing resources, gets bored, or decides that it's accurate enough. This is, essentially, Archimedes' approach - he calculated the perimeter of a 96-sided polygon and decided that was close enough. It's accurate to three places, which isn't a ton by today's standards, but it was the best anyone in Europe did for a very long time.

The approach that really got me thinking, though, was to place the value of pi between a known larger and known smaller value, then compare digits yielded by the two formulae. The value of pi is accurate as long as the corresponding digits agree.

"too small" formula < π < "too big" formula

That leaves deriving the formulae. It's relatively easy to find out the perimeter of a regular hexagon...


I know the angle a is 60 degrees because there are six triangles in the circle and 360 degrees is the total measurement they have to take up if they use all available real estate. Since it's a regular hexagon, they have to match each other. I can set the radius of the circle to be anything I want, so I'm going to make it 1. That means Rs, the radius of the smaller hexagon, is also 1. The ancients actually used a trigonometric function no longer in use, "chord" abbreviated "crd" quite frequently. Chord refers to the measurement of the chord of an arc with a given angle, so

Ps = crd(a)

Now all I have to do is multiply by six and I have the perimeter of the internal hexagon. It's not very close to pi, but it doesn't need to be yet. If I infinity was a number, I could set the number of triangles to infinity, calculate

∞Ps/d = π

and call it a day. Unfortunately, infinity's not a number. The other big problem I had was that I assumed that the trigonometric functions relied on knowledge of pi in their calculation, so I was having a chicken-and-egg issue in calculating the perimeters of my polygons.

I found this article on the chord function, though, that describes the calculation of a chord table to an arbitrary degree of accuracy based on special triangles and formulae for cutting angles into smaller and smaller pieces. Interestingly, Ptolemy uses a circle with radius 120 and measures the angle in 360 degrees, likely a throwback to the belief that the circumference of a circle is three times the diameter. It just goes to show that units of measurement are pretty arbitrary.

For my purposes, we'll say that the radius of the circle is 1, and we don't know the circumference. I'm going to stick with degrees as a unit of measurement because while I like radians better, they use pi in their definition and if I already knew pi, this whole exercise would be even more pointless. Then the perimeter of an inscribed polygon with n sides is

n*crd(360/n)

and

π ≈ n*crd(360/n)/2

It gets more equal as n approaches infinity:

π = limn→∞n*crd(360/n)/2

The problem is that infinity's not a number, which comes back to why I'm also interested in the perimeter of the outside polygon. Since I know the angle - it's whatever I want it to be - and I know the altitude of the triangle, which is the radius of the circle and which I've set to equal one, I can calculate the length of the base of the triangle, which is the length of one face of the polygon, as

Pl = 2tan(a/2)

In a polygon with n sides, the perimeter is

n*2tan(360/2n) = n*2tan(180/n)

So here's another way to calculate pi - the numbers will start too big, and approach pi as n approaches infinity.

π = limn→∞n*tan(180/n)

The twos cancel each other, so the equation's actually rather pretty.

What this all means in more practical terms, in a world in which we can't just throw infinity around and act like it's a calculable number is that

n*crd(360/n)/2 < π < n*tan(180/n)

n can be set to whatever number your calculator, computer, or patience with slicing angles in a trigonometric table can put up with, and you get a pretty good approximation of pi. For those whose calculators don't happen to have a chord function,

crd(θ) = 2sin(θ/2)

So the above formula for pi can be restated as

n*sin(180/n) < π < n*tan(180/n)

On my calculator, n must be set to 10,000 to get an accuracy of six places for either formula. If you really want to make your graphing device chug, try graphing these and watching them converge.

Here's the results using some different values of n

valuen*sin(180/n)n*tan(180/n)
633.464102
123.105893.21539
243.1326293.15966
483.139353.146086
963.1410323.142715
2003.1414633.141851
1,0003.1415873.141603
10,0003.1415933.141593

For reference, pi to seven places, from Wikipedia, is 3.1415927 - so the value of n of 10,000 is accurate to all the places I went to which should be adequate to prove my point.

1 comment:

Andrew said...

"prove my point" may not be a great phrase to use in the context of a math blog. What I'm trying to show is that the two values converge on pi.