Continued Fraction Converter - Best Rational Approximations
Math Calculators
Convert any decimal or fraction to its continued fraction representation [a₀; a₁, a₂, …]. Shows all convergents - the best rational approximations to any real number.
Enter a decimal or fraction (e.g. 22/7). Press Enter or click Convert.
Famous examples:
Continued Fraction
[3; 7, 15, 1, 288, 1, 2, 1, 3, 1, 7, 4]
Finite CF (rational number: 62831853/20000000)
Coefficients [a₀; a₁, a₂, …]
Convergents (best rational approximations)
| # | CF terms used | Fraction | Decimal | Error |
|---|---|---|---|---|
| 1 | [3] | 3/1 | 3.000000000 | 1.42e-1 |
| 2 | [3; 7] | 22/7 | 3.142857143 | 1.26e-3 |
| 3 | [3; 7, 15] | 333/106 | 3.141509434 | 8.32e-5 |
| 4 | [3; 7, 15, 1] | 355/113 | 3.141592920 | 2.70e-7 |
| 5 | [3; 7, 15, 1, 288] | 102573/32650 | 3.141592649 | 6.89e-10 |
| 6 | [3; 7, 15, 1, 288, 1] | 102928/32763 | 3.141592650 | 2.46e-10 |
| 7 | [3; 7, 15, 1, 288, 1, 2] | 308429/98176 | 3.141592650 | 6.52e-11 |
| 8 | [3; 7, 15, 1, 288, 1, 2, 1] | 411357/130939 | 3.141592650 | 1.26e-11 |
| 9 | [3; 7, 15, 1, 288, 1, 2, 1, 3] | 1542500/490993 | 3.141592650 | 2.95e-12 |
| 10 | [3; 7, 15, 1, 288, 1, 2, 1, 3, 1] | 1953857/621932 | 3.141592650 | 3.22e-13 |
| 11 | [3; 7, 15, 1, 288, 1, 2, 1, 3, 1, 7] | 15219499/4844517 | 3.141592650 | 1.07e-14 |
| 12 | [3; 7, 15, 1, 288, 1, 2, 1, 3, 1, 7, 4] | 62831853/20000000 | 3.141592650 | 0 |
What is a continued fraction?
A continued fraction is an expression of the form a₀ + 1/(a₁ + 1/(a₂ + 1/(a₃ + …))), written compactly as [a₀; a₁, a₂, …]. Every real number has a continued fraction expansion, and every rational number has a finite one.
When you enter a decimal, this tool reads its written digits as an exact base-10 rational
rather than converting it to a floating-point value first. For example, 0.0000001 is
normalized exactly to 1/10000000. The displayed decimal columns are
approximations for readability; the normalized fraction and continued-fraction arithmetic use
BigInt integers. Inputs are capped at 1,000 digits and expansions at 20 terms to keep the
calculation practical in the browser.
Famous continued fractions
- π = [3; 7, 15, 1, 292, 1, 1, 1, 2, …]
- e = [2; 1, 2, 1, 1, 4, 1, 1, 6, …] (beautiful pattern!)
- √2 = [1; 2, 2, 2, 2, …] (periodic)
- φ (golden ratio) = [1; 1, 1, 1, …] (all ones: "worst" approximable number)
- 355/113 = [3; 7, 16]: an unusually precise approximation of π
Why are convergents the best approximations?
A convergent pₙ/qₙ is closer to the target than any other fraction with denominator ≤ qₙ. This makes continued fractions the theoretically optimal tool for rational approximation: it's important in gear design, music theory (equal temperament), and calendar design (when is a year divisible by a simple fraction?).
The significance of large coefficients
A large coefficient aₖ (like 292 in π's expansion) means the previous convergent is an exceptionally good approximation. The fraction 355/113 is so accurate because the next coefficient is 292, meaning the next improvement requires a denominator roughly 292 times larger.
Connection to the Euclidean algorithm
The continued fraction expansion of a rational number a/b (where a > b) produces exactly the same sequence of quotients as running the Euclidean GCD algorithm on a and b. For example, to find gcd(34, 21):
34 = 1×21 + 13 -> quotient 1
21 = 1×13 + 8 -> quotient 1
13 = 1× 8 + 5 -> quotient 1
8 = 1× 5 + 3 -> quotient 1
5 = 1× 3 + 2 -> quotient 1
3 = 1× 2 + 1 -> quotient 1
2 = 2× 1 + 0 -> quotient 2 So 34/21 = [1; 1, 1, 1, 1, 1, 2] in continued fraction notation - the Fibonacci quotients, which is why consecutive Fibonacci numbers are the "worst case" for the Euclidean algorithm (requiring the most steps for their size). This deep connection between continued fractions and the GCD algorithm was known to Euler.
Related calculators
- Decimal to FractionConvert terminating or repeating decimals directly to exact fractions.
- FractionsUse a convergent in exact arithmetic after choosing an approximation.
- Number Theory ExplorerInspect properties of convergent numerators and denominators.
- Fibonacci GeneratorExplore ratios of consecutive Fibonacci numbers and their continued-fraction limit.