Continued Fraction Converter - Best Rational Approximations
Math Calculators
Convert decimals and fractions to continued fractions [a₀; a₁, a₂, …]. View each convergent, its exact fraction, and its decimal approximation.
Enter a decimal or fraction (e.g. 22/7). Press Enter or click Convert.
Famous examples:
Typed decimals are exact base-10 rationals. The π, √2, φ, and e examples use finite decimal approximations, not symbolic constants; expansions stop after 20 terms.
Continued Fraction
[3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2]
Expansion truncated after 20 terms; it did not terminate within the limit.
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.67e-7 |
| 5 | [3; 7, 15, 1, 292] | 103993/33102 | 3.141592653 | 5.78e-10 |
| 6 | [3; 7, 15, 1, 292, 1] | 104348/33215 | 3.141592654 | 3.32e-10 |
| 7 | [3; 7, 15, 1, 292, 1, 1] | 208341/66317 | 3.141592653 | 1.22e-10 |
| 8 | [3; 7, 15, 1, 292, 1, 1, 1] | 312689/99532 | 3.141592654 | 2.91e-11 |
| 9 | [3; 7, 15, 1, 292, 1, 1, 1, 2] | 833719/265381 | 3.141592654 | 8.72e-12 |
| 10 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1] | 1146408/364913 | 3.141592654 | 1.61e-12 |
| 11 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3] | 4272943/1360120 | 3.141592654 | 4.04e-13 |
| 12 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1] | 5419351/1725033 | 3.141592654 | 2.22e-14 |
| 13 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14] | 80143857/25510582 | 3.141592654 | 4.44e-16 |
| 14 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2] | 165707065/52746197 | 3.141592654 | 4.44e-16 |
| 15 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1] | 245850922/78256779 | 3.141592654 | 0 |
| 16 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1] | 411557987/131002976 | 3.141592654 | 0 |
| 17 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2] | 1068966896/340262731 | 3.141592654 | 0 |
| 18 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2] | 2549491779/811528438 | 3.141592654 | 0 |
| 19 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2] | 6167950454/1963319607 | 3.141592654 | 0 |
| 20 | [3; 7, 15, 1, 292, 1, 1, 1, 2, 1, 3, 1, 14, 2, 1, 1, 2, 2, 2, 2] | 14885392687/4738167652 | 3.141592654 | 0 |
How to use this tool
- Enter a number. Type a decimal (e.g. 3.14159) or a fraction (e.g. 355/113) into the input box. Decimal digits are treated as an exact base-10 rational.
- Click Convert. Press Convert to compute the continued fraction expansion.
- Read the CF notation. The result is shown as [a₀; a₁, a₂, …]. Each coefficient aᵢ is a positive integer (a₀ may be any integer).
- Explore convergents. The convergents table shows the best rational approximations from coarse (small denominator) to fine (large denominator), with their decimal error.
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
These patterns describe the exact mathematical constants. The π, √2, φ, and e buttons enter 50-digit finite decimal approximations, which are rational numbers; this tool displays at most 20 terms. Their prefixes match the familiar expansions at that precision, but a truncated decimal is not the symbolic constant itself.
- π = [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 π
A typed decimal is also interpreted as an exact base-10 rational. If its expansion does not finish within 20 terms, the result says it was truncated at that limit; it does not mean the entered decimal is irrational.
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.
Frequently asked questions
What is a continued fraction?
A continued fraction expresses a number as a₀ + 1/(a₁ + 1/(a₂ + 1/(a₃ + …))), written compactly as [a₀; a₁, a₂, a₃, …]. Every rational number has a finite continued fraction, while irrational numbers have infinite, non-repeating expansions (or infinite repeating ones for quadratic irrationals).
Are decimal inputs treated exactly?
Yes. The converter reads decimal digits directly and constructs an exact BigInt numerator and denominator before reducing the fraction; it does not first convert the input to a binary floating-point Number. Decimal values in the convergents table are display-only approximations, while exact fractions remain exact even when too large for a finite Number. Inputs are limited to 1,000 digits and output to 20 terms. The π, √2, φ, and e examples are finite decimal approximations, not symbolic constants.
What are convergents and why are they useful?
Convergents are the rational numbers obtained by truncating a continued fraction after each term. They are the best rational approximations to the original number in a precise mathematical sense: no fraction with a smaller denominator is closer to the target. The fraction 355/113 (accurate to 7 digits) is a convergent of π.
Why does 355/113 approximate π so well?
The continued fraction for π is [3; 7, 15, 1, 292, …]. Stopping after [3; 7, 15, 1] gives the convergent 355/113 ≈ 3.14159292…, which agrees with π to 6 decimal places. The large next coefficient (292) indicates this convergent is an unusually good approximation.
What is the difference between finite and infinite continued fractions?
Rational numbers have finite continued fractions; for example, 355/113 = [3; 7, 16]. Every value this converter accepts is an exact rational: a typed decimal is an exact base-10 fraction, and each famous-constant example is a finite decimal approximation. The display stops at 20 terms, so it reports a truncated expansion when that limit is reached rather than labeling the input irrational.
How accurate are the convergents?
Each convergent pₙ/qₙ satisfies |x − pₙ/qₙ| < 1/(qₙ·qₙ₊₁). The larger the next coefficient aₙ₊₁, the better the current convergent approximates x. This makes continued fractions the optimal tool for finding rational approximations.
Related tools
- 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.
- GCD & LCM CalculatorFollow the same Euclidean quotients while finding greatest common divisors and least common multiples.
- Ratio CalculatorScale convergent numerators and denominators to compare equivalent ratios.