Fraction Approximator
Convert any decimal to its closest fraction using the continued fraction algorithm. Shows all convergents with error values.
How to Use the Fraction Approximator
- Enter a decimal — type any decimal value (positive or negative). For example, enter 0.333333 to find that it approximates 1/3.
- Set a denominator limit — the max denominator slider limits how complex the fraction can be. Lower values give simpler fractions with more error; higher values give more accurate approximations.
- View convergents — the table shows all convergents from simplest to most precise, so you can choose the fraction that balances simplicity and accuracy for your use case.
- Simplify a fraction — switch to Simplify mode to reduce any fraction to lowest terms using the GCD algorithm.
What Is a Continued Fraction?
A continued fraction is a representation of a real number as a0 + 1/(a1 + 1/(a2 + 1/(a3 + ...))), where each aᵢ is a positive integer. Any real number can be expressed as a continued fraction. Rational numbers terminate (finite continued fractions); irrational numbers have infinite continued fractions. The algorithm extracts a0 = floor(x), then sets x = 1/(x − a0) and repeats. This process is closely related to the Euclidean algorithm for finding GCDs.
Convergents: Best Rational Approximations
A convergent is a fraction formed by stopping the continued fraction expansion at depth k. The key theorem of continued fractions is that convergents are the best rational approximations to a real number: if p/q is a convergent of x, then no fraction with denominator ≤ q is closer to x than p/q. This makes convergents uniquely valuable when you need a "nice" fraction that's close to a decimal value. Engineers use this when specifying gear ratios, sampling rates, or aspect ratios as small-denominator fractions.
The GCD and Simplification
A fraction a/b is in lowest terms when gcd(a, b) = 1 (they share no common factors). To simplify, compute gcd(a, b) using the Euclidean algorithm: gcd(a, b) = gcd(b, a mod b), repeating until b = 0. Then divide both a and b by the gcd. The Euclidean algorithm runs in O(log min(a,b)) steps and is one of the oldest algorithms in mathematics, described by Euclid around 300 BC.
Practical Applications
Fraction approximation is used in music (frequency ratios for tuning), electronics (resistor dividers), computer graphics (aspect ratios — 16/9 is a convergent of 1.777...), typography (em fractions), gearing (bicycle cassettes use Fibonacci-like ratios), and any situation where you have a measured decimal but need a manufacturable ratio. In display technology, 1920/1080 = 16/9 exactly; in audio, 44100/48000 = 147/160 is the simplification of the CD-to-DAT sample rate ratio.