What this calculator does
A continued fraction rewrites a number as a whole part plus one over a whole part plus one over another, and so on. The expansion terminates for any rational number, and the terms encode its structure remarkably compactly.
The convergents are the payoff: each is the best rational approximation with a denominator that size. Expanding 355 over 113 gives [3; 7; 16], and that fraction is the famous approximation to pi accurate to seven digits.
The formula
The whole part is taken, then the process repeats on the reciprocal of the remainder. Each step yields one term, and the convergents are built up from those terms by a recurrence.
| Term | Meaning |
|---|---|
| Continued fraction | A number written as nested reciprocals of whole numbers. |
| Convergent | A partial expansion, giving the best rational approximation for its denominator. |
| Terms | The whole numbers appearing at each level of the nesting. |
The inputs explained
| Field | What to enter |
|---|---|
| Numerator p | The numerator of the fraction to expand. |
| Denominator q | The denominator. Cannot be zero. |
When to use it
Finding a good rational approximation
Convergents are provably the best approximations for their denominator size.
Understanding pi approximations
22/7 and 355/113 are both convergents of pi.
Working with gear ratios
Approximating an awkward ratio with small whole numbers is exactly this problem.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
How does the denominator change the expansion?
The same numerator over three denominators.
| Denominator | Continued fraction | Final convergent |
|---|---|---|
| 355/7 | [50; 1; 2; 2] | 355/7 |
| 355/100 | [3; 1; 1; 4; 2] | 71/20 |
| 355/113 | [3; 7; 16] | 355/113 |
Questions
Why is 355/113 special?
Because it approximates pi to seven decimal places with a denominator of only 113, which is remarkable efficiency. It arises as a convergent of pi's continued fraction, and the unusually large next term is what makes it so accurate.
Do all numbers have a continued fraction?
Yes. Rational numbers give finite expansions, which is why this calculator terminates. Irrational numbers give infinite ones, and quadratic irrationals like the square root of two give infinite but periodic expansions.
What makes convergents the best approximations?
A theorem guarantees that no fraction with a denominator smaller than a given convergent comes closer to the target. That optimality is what makes continued fractions the right tool for rational approximation.
What is the continued fraction for the golden ratio?
All ones: [1; 1; 1; 1; ...]. That makes it the hardest number to approximate rationally, since every term contributes the minimum possible. It is sometimes called the most irrational number for exactly that reason.
For the ratio with the simplest expansion, see the golden ratio calculator. For the sequence whose ratios converge to it, see the Fibonacci calculator.