Wednesday, April 11, 2012

Rational Approximations to Pi

Physics is my territory, not mathematics. Even so, after posting a hundred and twenty-something blog articles over the last two years, it's hard to believe I haven't done any straight-up math topics. Today I'm going to break my rule.

You will see that what follows is not the work of a mathematician, or even a physicist. At best, it represents the efforts of an engineer. (For a superb mathematical summary, check out this web article by David Bau.) And yet, I feel there is a certain charm to my method.

I didn't start out to write about pi. I was going to write about a couple of approximations I worked out over the years for approximating curves. One was an approximation for arc lengths, and the other was for the area of curved surfaces. Both of them are vaguely related to the well-known approximation for a circular segment as two-thirds the area of the circumscribed rectangle. This approximation becomes exact for the case of a parabola:
If you don't know this already, you really ought to. I end up using this approximation in my calculation of pi.

My method is based on complex numbers. You know that in complex algebra, if you take a number like 4+3i and square it, cube it, etc, you generate complex vectors that rotate around the origin in steady angular increments. This is a consequence of the general rule that when you multiply complex numbers, you multiply the magnitudes and add the angles. If you don't want to keep track of the ever-swelling magnitude, you can just normalize everything by dividing your original vector by its length.

It's a funny point that you can never get back to your original angle by this method. You can come awfully close, but you'll never return to your starting angle. Which is another way of saying you'll never project your vector exactly onto the x or y axis, no matter how many times you circle the origin. For example, given the vector (4+3i)/5, it turns out that the 22nd power is 0.09928 + 4.999i , which is very close to the positive y axis. The 83rd power comes even closer: at -4.99996-.0176i, it is ever so close to the minus-x axis. Clearly, our vector is a very close approximation to the 166th root of unity.

How can we leverage this information to get an approximation for pi? Well, one way is to use our approximation for the area under a curve. Taking it to be two-thirds of the circumscribed rectangle, we get this from the geometry:

From what I've already said about the powers of 4+3i, it should be clear that eleven such sectors are very nearly five-fourths of a full circle...actually, that's wrong, because by the time you take 22 powers, you've actually circled the origin twice, so we're looking at nine-fourths of the area of the circle. From this we get the following rational approximation for pi:

How good is this? In decimal notation, it comes to 3.12888, which is OK but not all that brilliant. We can actually fix it up just a bit by noticing that there was a sliver of pie missing...the width 0.09928 which I mentioned earlier, and which would have contribued an extra area of close to 0.25. This correction inches us up to 3.13000, but it's clearly still short by close to 1%.

It's not hard to guess the source of error: it's the parabolic approximation for the circular sector which is to blame. Yes, I just finished saying what a great approximation it is, but we're now facing the famous historical approximation to pi which are renowned for their accuracy. Actually, you really ought to read that article by David Bau that I referenced at the start of this post...he shows how even the homely 22/7 that we're all familiar with is in fact a much much better approximation than anyone has a right to expect. But that's another story.

The main reason the parabolic area approximation falls short for us in this case is that we're taking to big a bite. The approximation becomes better as you work with shallower circular arcs. I wanted to stick to rational approximations, so I looked for trianges similar to 3-4-5 except thinner, so we work with shallower arcs. Such triangles are easy to construct, and the 11-60-61 triangle gives us some nice values.

Without redrawing the same pictures, what I found in EXCEL was that the 26th power of the complex vector falls very near the negative-y axis. The exact value is 0.1174 - 60.9999i. This represents three-quarters the area of the unit circle. What about the area of the sector? Well, the two triangles add up to 660, and the circular arc enclose, by our approximation, an additional 44/3. So, just as we did with our last calculation, we get the following result:

Converting this to decimal, we get a value of 3.14276, which is just ever-so-slightly better than the old traditional 22/7 (decimal 3.14286)! What about the pie-sliver correction we made in our 3-4-5 analysis? It didn't help us much in that situation, but this time, it is actually quite helpful indeed. The sliver of width 0.1174 gives us an area of 3.74; when we factor this in to the calculation above, it adjusts our value of pi to 3.14142...a significant improvement. Clearly, the approximation becomes much much better as the arc becomes more shallow. But it's still not nearly as good as the next best fractional value, 355/113, which gives us 3.1415929..., diverging from the true value of pi only in the seventh decimal place!

Although I do not seem to be competing for accuracty and economy of computational resources with other methods, it is somewhat noteworthy that my techniqes do lead to rational least up to the point where I do the sliver correction. As David Bau points out, the modern extremely accurate and rapidly-converging series for pi come not from geometry but from analysis. And as good as they are, they do not tend to give rational expressions; in particular, the elusive 355/113 seems to defy all attempts at "rational" explanation. 

It is an inexplicable fact of human nature that I, and others like me, will nevertheless continue to play around with our primitive methods, hoping against all odds to stumble upon the key to unlock the secrets of pi and its rational approximations. Although we are almost certainly doomed to failure, we just can't turn and walk away.

No comments: