Continued Fraction Calculator and Rational Approximation Tool
Convert an exact fraction or finite decimal into a simple continued fraction, inspect its convergents, and find the closest fraction within a denominator limit. Your input stays in your browser.
Enter a rational value
Examples: 43/30, -2.75, or 1.25e-4. Up to 300 significant digits and an exponent from โ1,000 to 1,000.
Expansion and approximation
Your result will appear here.
With 355/113, select Calculate to see [3; 7, 16] and all three convergents.
What is a simple continued fraction?
A simple continued fraction writes a number using an integer part and reciprocals of positive integers. The compact notation [aโ; aโ, aโ, โฆ] means:
aโ + 1/(aโ + 1/(aโ + 1/(โฆ)))
For a rational input, repeated Euclidean division eventually reaches remainder zero, so the expansion is finite. This tool uses the canonical finite form: the final term is greater than 1 unless the value is an integer.
For negative values, a0 is the mathematical floor. For example, โ22/7 = [โ4; 1, 6], with every term after the first remaining positive.
How the calculation works
Parse the text as an exact numerator and positive denominator, then reduce by their greatest common divisor.
Take a0 = floor(n/d) and keep the non-negative remainder.
Replace n/d with d/r and repeat until the remainder is zero.
Build convergents from the recurrence at right.
For the denominator limit, check the last eligible convergent and the boundary intermediate fraction, then compare their exact errors.
The quotients are 3, 7, and 16, giving [3; 7, 16].
Convergents
3/1, 22/7, 355/113
Each added term refines the fraction. With a maximum denominator of 100, the closest allowed result is 311/99; intermediate fractions can beat the last full convergent when the limit falls between convergent denominators.
Input meaning and limits
Input
Exact value used
43/30
The entered numerator divided by the entered nonzero denominator, reduced exactly.
0.125
The finite decimal 125/1000 = 1/8, not an approximate binary floating-point value.
1.25e-4
The exact decimal 0.000125 = 1/8000.
Decimal digits of ฯ or โ2
The finite digits entered. The tool does not infer a named irrational constant.
Limits: 300 significant digits; scientific exponent from โ1,000 to 1,000; maximum denominator from 1 to 1,000,000,000,000; and at most 200 displayed terms. If an exact expansion is longer than the display limit, the approximation still uses the complete input value.
Continued fraction FAQ
What is a convergent?
A convergent is the exact fraction obtained by stopping at a term of the continued fraction. Its numerator and denominator come from the recurrence above.
Is the last convergent always the best fraction under my denominator limit?
Not always. When a limit lies between two convergent denominators, an intermediate (semiconvergent) fraction may be closer. The bounded-denominator result checks the relevant boundary candidate as well as the last eligible convergent.
Can this calculator expand ฯ or โ2 exactly?
No. Irrational numbers have infinite non-repeating continued fractions and cannot be supplied exactly as a finite decimal. Example buttons use finite decimal approximations and clearly treat those digits as the exact input.
Why can the same rational number have two finite forms?
If the last term is greater than 1, it can be replaced by one less followed by 1. For example, [3; 7, 16] = [3; 7, 15, 1]. This tool returns the shorter canonical form ending above 1.
How are negative numbers handled?
The first term is the floor of the value, not truncation toward zero. Later terms are positive, so the output remains a standard simple continued fraction.
Are decimal inputs affected by floating-point rounding?
No. The decimal text is converted directly into a ratio of integers and simplified. Approximate decimal previews are for readability; fractions and error ratios are exact.
Are my inputs private?
Yes. Parsing, continued-fraction expansion, and rational comparison happen locally in your browser. Inputs are not uploaded, stored, or added to the page URL.