6

$\frac{355}{113}$ is a surprisingly good rational approximation of $\pi$. If you define the quality of a rational approximation $\frac{a}{b}$ as minimizing $\log(ab)+\log(|\frac{a}{b}-\pi|)$, is it the best possible approximation?

Using the stated quality metric, the four best approximations of $\pi$ for denominators less than $10^8$ are (in decreasing order of quality) $\frac{355}{113}$, $\frac{22}{7}$, $\frac{5419351}{1725033}$, and $\frac{3}{1}$.


  • 6
    Maybe you will be interested in the theory of continued fractions – Norse Jan 12 '20 at 16:31
  • Why do you use the term "log(ab)" in the quality-funtion ? – Peter Jan 12 '20 at 16:48
  • 1
    @Peter. He doesn't want the best approximation (which obviously doesn't exist). 355/113 is "surprisingly good", that is a very good approximation with a fraction with small numerator and denumerator. Question: Are there approximations where the approximation is better, taking the size of the numbers involved into account? – gnasher729 Jan 12 '20 at 17:16
  • @Peter - gnasher729 stated it better than I could. :-) – Omnifarious Jan 12 '20 at 17:26
  • 3
    I'm interested in how you came across that quantity that you have asked to minimize. The reason I ask is that from standard continued fraction theorem, which gives a constant $c>0$ (a very specific number which I forget at the moment), for which there exist infinitely many rational numbers $a/b$ satisfying the inequality $$\left|\frac{a}{b}-\pi \right| < \frac{c}{b^2}$$ And I notice that this inequality is equivalent to $$\log(ab)+\log(|\frac{a}{b}-\pi|) < \log\left(c \frac{a}{b}\right)$$ But the right hand side is not small, in fact it is close to $\log(c\pi)$. – Lee Mosher Jan 12 '20 at 21:38
  • 3
    @LeeMosher - I think of $\log$ as the answer to "How many digits does the number have?". But, of course, when comparing how close the result is to $\pi$ you will get 'negative digits', which can be interpreted as how many digits of precision there is in the approximation. So, I just added the two together. What's "the biggest bang for the buck"? What's the smallest number of digits that buys you the largest number of digits of precision? It's interesting that it has a relation to something in continued fraction theory, something I know almost nothing about. – Omnifarious Jan 12 '20 at 21:48

1 Answers1

12

Interesting question. The answer is no: there are better approximations than $\frac{355}{113}$ (according to your metric), but they involve really big numbers.

As a number of commenters mentioned, continued fractions are the key to understanding this. The continued fraction of $\pi$ is

$$\pi = 3 + \cfrac{1}{7 + \cfrac{1}{15 + \cfrac{1}{1 + \cfrac{1}{292 + \ddots}}}}$$

(Sometimes the more compact notation $\pi = [3; 7, 15, 1, 292, \dots]$ is used.)

We can approximate $\pi$ by cutting off this infinite continued fraction at some point. These truncations of the continued fraction are called convergents. The first few for $\pi$ are $$3 = \cfrac{3}{1}, \quad 3 + \cfrac{1}{7} = \frac{22}{7}, \quad 3 + \cfrac{1}{7 + \cfrac{1}{15}} = \frac{333}{106}, \quad \text{and} \quad 3 + \cfrac{1}{7 + \cfrac{1}{15 + \cfrac{1}{1}}} = \frac{355}{113}.$$

An important fact about convergents of the continued fraction of a number $x$ is that they are best rational approximations of $x$. This means that if $\frac{p}{q}$ is a convergent of $x$, then $|x - \frac{p}{q}|$ is smaller than $|x - \frac{a}{b}|$ whenever $b \leq q$. Thus, $\frac{22}{7}$ is closer to $\pi$ than any fraction with denominator less than or equal to 7, $\frac{333}{106}$ is closer than any fraction with denominator less than or equal to 106, etc. (Confusingly, while every convergent is a best rational approximation, the converse is not true; not every best rational approximation is a convergent.)

So convergents provide pretty good approximations of a given denominator size. What's more, a given convergent will be especially close when the next term in the continued fraction is large. That's why $\frac{355}{113}$ is so close to $\pi$, because $\frac{355}{113} = [3; 7, 15, 1]$, and the next term in $\pi$'s continued fraction is 292, which is quite large.

In fact, suppose a given convergent is $\frac{p_n}{q_n}$. And suppose the next term in the continued fraction is $a_{n + 1}$. One can show, using Theorems 2 and 5 here, that we will have $\frac{1}{(a_{n + 1} + 2)q_n^2} < |x - \frac{p_n}{q_n}| < \frac{1}{a_{n + 1}q_n^2}$. For example, $\frac{1}{294\cdot 113^2} < |\pi - \frac{355}{113}| < \frac{1}{292\cdot 113^2}.$

For your problem, we're trying to find $a$ and $b$ to make $\log(ab) + \log(|\pi - \frac{a}{b}|)$ as small as possible. Observe that $a$ will be extremely close to $\pi b$, so essentially, we're trying to minimize $\log(\pi b^2) + \log(|\pi - \frac{a}{b}|) = \log(\pi b^2|\pi - \frac{a}{b}|)$. Since $\log$ is a monotone increasing function, this is the same as minimizing $\pi b^2|\pi - \frac{a}{b}|$, and of course we can drop the $\pi$ off there, so we want to make $b^2|\pi - \frac{a}{b}|$ as small as possible. For $\frac{355}{113}$, we know from above that $\frac{1}{294} < 113^2|\pi - \frac{355}{113}| < \frac{1}{292}$.

So the question becomes: can we find some term in $\pi$'s continued fraction that's larger than 292? We can, though we have to go pretty far in the sequence to find it. Here you can see that eventually 436 appears in the continued fraction of $\pi$. (Then not too long after that 20776 appears! But let's stick with 436.) For the convergent $\frac{p}{q}$ that comes just before that 436 term, we will have $\frac{1}{438} < q^2|\pi - \frac{p}{q}| < \frac{1}{436}$. So presumably this convergent will be smaller for your metric than $\frac{355}{113}$ is.

In fact, according to my calculations this convergent is given by $\frac{p}{q} = $

$\frac{47449023823422717451594836169381198840134089164995011450245185618387776847176840854174067173766596944222479515740143273879768480709913455315809719544718248}{15103493372765657274145753764324412346673615736564990480645229502691940095166708783466819743670409392336434093031760588386010342390699617474201564040715683}$

This differs from $\pi$ by about $1.003324411\cdot 10^{-311}$. Your metric is therefore equal to $\log(pq) + \log(|\pi - \frac{p}{q}|) = 308.855304691 - 310.998558621 = -2.143253930$ (assuming base-10 log; natural log would just be a multiple of this). By comparison, for $\frac{355}{113}$ your metric is $4.603306797 - 6.573872472 = -1.970565675$.

It's suspected, but not known, that the terms (a.k.a. partial quotients) in $\pi$'s continued fraction are unbounded. If that's true, then no approximation of $\pi$ will be optimal for your metric; rather, we will keep on finding approximations that make it lower and lower (with no lower bound).