Best Rational Approximation Calculator
Find the best fraction approximation for any decimal number using continued fractions.
Shows the top 5 rational approximations within a denominator limit.
Rational Approximation
Every irrational number (like π or √2) can be approximated by a fraction p/q. The challenge is finding the best fraction, the one that gives the smallest error for the smallest denominator.
Continued Fractions
Any real number can be written as a continued fraction: x = a₀ + 1/(a₁ + 1/(a₂ + 1/(a₃ + …)))
Written as [a₀; a₁, a₂, a₃, …]
The convergents (truncations of this expansion) give the best rational approximations, better than any other fraction with a smaller denominator.
Famous Examples
| Number | Decimal | Fraction | Relative error |
|---|---|---|---|
| π | 3.14159265… | 22/7 | 0.0402% |
| π | 3.14159265… | 333/106 | 0.00265% |
| π | 3.14159265… | 355/113 | 0.0000085% |
| e | 2.71828183… | 87/32 | 0.0172% |
| √2 | 1.41421356… | 99/70 | 0.0051% |
| φ (golden ratio) | 1.61803399… | 89/55 | 0.0091% |
Why 355/113 is remarkable
355/113 = 3.14159292…, which matches π to six decimal places using only three digits top and bottom. What makes it stand out is the jump. The convergent before it, 333/106, is already good at 0.00265%, but 355/113 is roughly 300 times better while adding only 7 to the denominator. That leap happens because the next term in π’s continued fraction expansion is 292, an unusually large number, and a large term means the truncation before it was already very close. The Chinese mathematician Zu Chongzhi found 355/113 around 480 AD and called it the 密率, the “close ratio”. Europe did not match it for another thousand years.
Convergents are not the whole story
A convergent is the best approximation in a strict sense: no fraction with a smaller denominator gets closer. But when you cap the denominator at some awkward value, the winner is often a semiconvergent, formed by taking a partial step toward the next convergent.
Cap the denominator at 100 and ask for π. The convergents available are 3/1 and 22/7, since 333/106 is already too big. Yet 311/99 fits comfortably and is about seven times closer than 22/7. It is a semiconvergent, sitting fourteen steps of the way from 22/7 toward 333/106.
This calculator checks the semiconvergents as well, which is why it can return a fraction you will not find in a table of convergents.
The Stern-Brocot Tree
Every positive fraction appears exactly once in this infinite binary tree, in lowest terms. Walking down it by repeatedly taking the mediant (a+c)/(b+d) of the two fractions bracketing your target generates exactly the convergents and semiconvergents above, which is why the two methods always agree.
How we build and check this calculator
This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.
SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.