How Close a Fraction Can Get

Pick a number and how many terms to keep. The card on the left is the fraction the continued fraction gives you; the line under it searches every fraction with a smaller denominator and reports the closest one it can find.

Loading interactive simulation...

The best fraction of its size, searched for rather than asserted

Set √2 and four terms and the tool hands back 17/12. Then it does the part worth having a tool for: it takes every denominator below 12, finds the nearest numerator for each, and reports the closest fraction it can build. That is 7/5, and it is 5.8 times further from √2 than 17/12. Truncating a continued fraction does not merely give a good fraction — it gives the best one available at that size, and the page would rather show you the search than name the theorem. Press The 355/113 surprise and the same sweep runs over every denominator up to 112. The best of them is 333/106, which is 312 times further out.

A large term means the fraction before it was already very good

π is [3; 7, 15, 1, 292, 1, 1, …], and the 292 is the one to look at. A large term means the leftover at that point was very nearly nothing, which is another way of saying the fraction you were already holding was very nearly exact. So 355/113, the convergent immediately before it, gets seven significant figures out of a three-digit denominator, while 22/7, which is followed by a mere 15, manages three. The size of the next term is what tells you how good the fraction in your hand already is. It is also why 355/113 was worth finding in fifth-century China and is still the fraction anyone reaches for.

The golden ratio is the hardest number to approximate, and that is a measurement

Multiply each error by the square of its denominator and fractions of different sizes become comparable. Do it for √2 and the column settles at 0.354. Do it for φ and it settles at 0.447 — and that number is 1/√5, which no irrational can stay above for ever. φ is the number that presses hardest against that ceiling, and the reason is sitting in its expansion: every term is 1, the smallest a term is allowed to be, so every convergent is the least possible improvement on the one before. Calling φ the most irrational number sounds like a flourish. It is a measurement, and this is the column it lives in.

Problem solved in full

  1. Showing 355/113 is the closest fraction to π with a denominator under 1000 7 steps

    Show that 355/113 is the closest fraction to π with a denominator under 1000, and find out how far its reign actually runs.

    1. Run the expansion first. π = [3; 7, 15, 1, 292, …], so the convergents are 3, then 22/7, then 333/106, then 355/113.

      π=[3;7,15,1,292,…]\pi = [3; 7, 15, 1, 292, \ldots]
    2. Each convergent comes from the two before it: multiply by the new term and add the one further back. Nothing in that step needs π itself, only its terms.

      pnqn=anpn−1+pn−2anqn−1+qn−2\frac{p_n}{q_n} = \frac{a_n p_{n-1} + p_{n-2}}{a_n q_{n-1} + q_{n-2}}
    3. 355/113 comes out at 3.1415929204 against π's 3.1415926536. The error is 2.7 × 10⁻⁷, which is seven significant figures from three digits over three digits.

      355113=3.1415929204…,π=3.1415926536…\tfrac{355}{113} = 3.1415929204\ldots, \qquad \pi = 3.1415926536\ldots
    4. Now the search. Take every denominator from 1 to 112, pick the nearest numerator for each, and keep the closest result. The winner is 333/106, out by 8.3 × 10⁻⁵ — 312 times further than 355/113.

      min⁡q≤112∣π−pq∣=∣π−333106∣≈8.3×10−5\min_{q \le 112} \left|\pi - \tfrac{p}{q}\right| = \left|\pi - \tfrac{333}{106}\right| \approx 8.3 \times 10^{-5}
    5. Widen the search to 1000 and nothing new appears. 355/113 is still the closest fraction there is.

    6. So how far does it hold? Sweeping upward, the first fraction that beats it is 52163/16604. That means 355/113 is the closest fraction to π for every denominator up to 16,603.

      5216316604  first beats it:  q×147,  error−0.2%\tfrac{52163}{16604} \;\text{first beats it}: \; q \times 147, \; \text{error} -0.2\%
    7. And look at what beating it buys. 52163/16604 has a denominator 147 times larger and reduces the error by 0.2%. That is the shape of the whole subject: the good fractions are enormously better than their neighbours, and the next real improvement is a long way up.

    Answer

    355/113, out by 2.7 × 10⁻⁷, and the closest fraction to π for every denominator up to 16,603. Where this stops is the part worth knowing. √2 runs 2, 2, 2, … for ever and e runs 1, 1, 2, 1, 1, 4, 1, 1, 6, …, so both patterns can be stated and proved. Nobody knows a pattern in π's terms. Nobody knows whether they stay bounded, or whether some vast term is waiting further out and with it a fraction far better than 355/113. The 292 is not explained by anything. It is simply what π does.

Learning path

Writing a number down

Further reading (1)