Recall the challenge I posed in a previous post: given the sequence of integers , what can you learn about (assuming you didn’t know anything about it before)? The answer, as explained in another post, is that you can learn to whatever precision you like, if you wait long enough. Not only that, but you can do better than is initially obvious. You can learn n digits of the decimal expansion of if you wait for , but this is throwing away too much information: instead, noting that , we get upper and lower bounds on from each term in the sequence:

Let’s graph these upper and lower bounds for various values of n:

Neato! We can view this in a slightly different way by graphing the error (the amount under or over ) of the approximations instead of the approximations themselves:

So, that looks pretty cool… but the best approximations quickly get so close to that it’s hard to see what’s really going on. So now we’re going to (a) zoom way out—the graph will go to n = 50000 instead of just 200, and (b) use a log-log scale—that is, we’ll graph the logarithm of both the error and n.

Cool! Now we can see some more interesting structure at the bottom of the graph (in the previous graph, the approximations quickly got so close to the axis that it was impossible to tell what was going on; this is why plotting the logarithm of the error helps). We can see that most of the approximations are in that big mass sloping gently down and to the right. This represents about how well we would do at approximating pi if we just looked at the th elements of the sequence. But the interesting thing is the approximations which are not part of that big mass. At several places—most notably at around n=5, n=100, and n=30000—there are downward spikes, representing approximations which jump out as being way better than most of the other ones at that point. These are precisely the convergents of , which are (in a specific technical sense) the best rational approximations to . This is why, by looking at all the approximations and choosing the best ones, we can do much better than just looking at the th elements of the sequence (imagine a line drawn through the bottommost points in the graph; it’s much steeper than the average slope of the big mass of approximations above it). In a future post I hope to write a bit more about these so-called “convergents” and where they come from; I’ve actually written a bit about them before, but didn’t point it out at the time!

5 Responses to Predicting pi: pretty graphs and convergents

What’s more, the downward spikes (in general) converge about twice as fast as the big mass of approximations. That is, the best approximation of a real number x by rationals with denominator less than n is good to about 1/n^2. (This result is known as “X’s Theorem” for some name X that I can’t remember now.)