InfyCalculator
➗

Continued Fraction Calculator

Expand a decimal into its continued fraction and read off the best rational approximations (convergents) to the value.

Decimal value
Max terms
Loading calculator…

How it works

x = a₀ + 1/(a₁ + 1/(a₂ + …)) where aₙ = ⌊xₙ⌋ and xₙ₊₁ = 1/(xₙ − aₙ) · convergents hₙ/kₙ via hₙ = aₙhₙ₋₁ + hₙ₋₂

A continued fraction expands a number as an integer plus one over another continued fraction, peeling off the whole part and inverting the remainder at each step. Truncating the expansion gives the convergents — the best possible rational approximations for their size, which is how 22/7 and 355/113 arise for π. The list of coefficients [a₀; a₁, a₂, …] is the fingerprint of the number.

Worked example

For 3.14159265, the coefficients start [3; 7, 15, 1, …]. Truncating after 3 and 7 gives 22/7 ≈ 3.142857; carrying further to [3; 7, 15, 1] yields 355/113 ≈ 3.1415929, accurate to six decimals.

Sources: Continued fraction — Wikipedia

Frequently asked questions

What is a convergent?

A convergent is the fraction you get by cutting the continued fraction off after a few terms. Each convergent is the closest rational approximation to the value for any denominator that size or smaller.

Why is the result only approximate?

A finite decimal is expanded to a limited number of terms, so the last convergent is a very close rational — but for irrational numbers like π no finite fraction is exact. The reported error shows how close it lands.

How do I read the bracket notation?

In [a₀; a₁, a₂, …], a₀ is the whole-number part and each following term is a denominator in the nested fraction. [3; 7] means 3 + 1/7 = 22/7.

Related calculators

This calculator is for educational purposes. Double-check important results before acting on them.