Index | Partial quotient | Numerator | Denominator | Decimal approximation | Absolute error | Relative error (%) |
---|
Continued fractions offer a systematic way to recover the best rational approximation of any real number when you have no guarantee about its algebraic structure. Engineers run into them when designing low-order digital filters, cryptographers confront them when assessing short RSA keys, and students brush against them when discovering that the charming fraction 22/7 is only the second convergent for the circle constant π. Yet continued fractions can feel abstract and untethered from practical intuition. This explorer grounds the theory by letting you enter any number—whether it is a constant like e, a ratio you measured in the lab, or a decimal reported by a simulation—and watching how the convergents tighten around it. Each row in the results table represents a distinct level of approximation, showing the numerator, denominator, decimal expansion, and error metrics that tell you how far the approximation deviates from the original value.
The first step in the workflow is identifying the target number. You may paste a long decimal string, convert a fraction, or type the name of a common constant. The tool even interprets square roots so you can explore quadratic irrationals like √2 or √5. Once the number is parsed, the classical Euclidean algorithm decomposes it into partial quotients. Each quotient defines a convergent through the recurrence relations that underpin continued fractions. Even though the algorithm dates back to ancient mathematics, its behavior still impresses: the numerators and denominators grow quickly, yet the approximation often improves even faster. When a decimal with no obvious pattern suddenly matches a simple fraction with a small denominator, you are seeing Diophantine approximation in action.
The calculator follows the textbook recurrence for simple continued fractions. Given a sequence of partial quotients a0, a1, …, an derived from your number, the numerators pn and denominators qn satisfy a pair of linear recurrences. At each step, a new convergent emerges from the two that came before. That is why the algorithm keeps track of the “minus two” and “minus one” terms in code: without them the recurrence would stall. The MathML block below expresses the recurrence in symbolic form.
In plain language, each new numerator is the current partial quotient multiplied by the previous numerator, plus the numerator before that. The same goes for denominators. The Explorer implements this recurrence verbatim and stops when the remainder term vanishes or when you hit the depth limit. Because continued fractions of rational numbers terminate, fractions like 355/113 produce a finite sequence; irrational targets keep producing new convergents until the depth cap stops the process. The absolute error column reports how close the approximation is, while the relative error translates that deviation into a percentage of the original magnitude so you can compare approximations across vastly different scales.
Suppose you are designing a mechanical linkage and encounter the square root of two. Your CAD program reports 1.41421356237, but the dimensions must be expressed as rational fractions because you are ordering custom gears with limited tooth options. Enter “sqrt(2)” into the tool, set the depth to 10, and leave the tolerance at 10−6. The convergent table begins with 1/1 and 3/2, both of which you might already know from geometry class. As you scroll downward, you encounter 17/12, 41/29, and 99/70. These approximations already achieve four decimal places of accuracy. The sixth convergent, 239/169, crosses the tolerance you supplied: its absolute error is about 8.3×10−7. That means if your application can tolerate an error of less than a micrometer on a meter-long part, 239/169 is sufficient. The Explorer flags this automatically in the summary sentence, saving you from manual verification.
Why not simply round the decimal to the nearest rational with a fixed denominator? The reason is that continued fractions search the space of all possible denominators, not just the convenient ones. If you limited yourself to denominators under 200, you would still find 239/169 because the convergents of √2 yield the best approximation for each denominator limit. This property, articulated formally in the theory of best approximations, is why continued fractions power attack algorithms in cryptography and resonance calculations in physics. The Explorer reinforces that behavior by displaying the denominators next to their errors. You can see at a glance whether doubling the denominator halves the error, or whether a modest increase yields a dramatic improvement.
To appreciate how different numbers behave, try contrasting three targets: π, e, and the Feigenbaum constant δ ≈ 4.669201609. The table below summarizes how quickly the first few convergents converge for each value.
Target | Convergent reaching 10−4 | Denominator size | Absolute error |
---|---|---|---|
π | 355/113 | 113 | 2.67×10−7 |
e | 193/71 | 71 | 3.08×10−6 |
Feigenbaum δ | 1181/253 | 253 | 7.29×10−6 |
Pi yields the spectacular 355/113 approximation that clocks in at an error below three parts per million, far surpassing what you would expect from such a small denominator. The base of natural logarithms is less cooperative: its continued fraction has repeating patterns but produces slower convergence. Chaotic systems constants like δ require larger denominators before you see comparable accuracy. The Explorer quantifies these differences so you can plan for them. If you know you can only fabricate parts with denominators up to 200, π is safe but δ might not be—important knowledge when designing precision machinery or calibrating experimental apparatus.
The absolute and relative error columns provide different lenses on the same deviation. Absolute error is expressed in the native units of the number you entered; if you are approximating a ratio of lengths, the error is measured in those units, and if you entered a dimensionless constant, the error is purely numerical. Relative error divides that deviation by the target magnitude so you can compare approximations of numbers that live on different scales. Consider approximating Avogadro’s constant (about 6.022×1023) versus the fine structure constant (approximately 0.007297). An absolute error of 0.001 is immaterial for Avogadro’s constant but catastrophic for the fine structure constant. The table reports both so you do not have to mentally normalize. When you export the CSV, these metrics remain intact, letting you plot error decay across convergents or feed the series into optimization software to search for denominators that match your design constraints.
Teachers often ask for ways to demonstrate number theory concepts interactively, and researchers sometimes need to document the approximations used in simulations. The CSV export supports both use cases. In a classroom, you can assign each student a different constant, download the convergents, and have them graph how the error shrinks; the pattern is strikingly linear on a semilog plot for quadratic irrationals. In an engineering lab, you can import the CSV into a spreadsheet that already houses tolerances and fabrication limits. Because each row includes the numerator and denominator explicitly, it is easy to append additional columns for unit conversions, tolerances, or even procurement part numbers. The Explorer also retains the index of each convergent, which is helpful when cross-referencing to theoretical results that refer to the “fifth convergent” or the “seventh convergent with even parity.” The export turns a one-off calculation into a reusable data set.
Continued fractions surface in surprising corners of applied science. Radio engineers use them to design impedance-matching networks with minimal components, approximating target impedances with convergents that correspond to cascaded sections of transmission line. Cryptanalysts monitor convergents when testing RSA keys for vulnerabilities—if the private exponent is too small, a convergent of the public fraction betrays it. Even chefs experimenting with fermentation ratios may find that a convergent with a small denominator keeps ingredient ratios manageable. The Explorer’s ability to digest any decimal means you can paste measurements from spectroscopy equipment, astronomical observations, or musical tuning experiments and immediately see which rational approximations make sense. By saving and comparing CSV exports, teams can build libraries of preferred approximations that align with their manufacturing tolerances or artistic sensibilities.
Despite its power, the Explorer makes several simplifying assumptions. It uses JavaScript’s double-precision floating point arithmetic, which means extremely deep expansions of numbers close to machine precision may accumulate rounding error. For most practical applications, especially with denominators under a few million, this is negligible. The parser accepts simple expressions but not full symbolic arithmetic; if you need continued fractions of expressions like (√5 + 1)/2, enter their decimal or evaluate them externally. The error metrics rely on absolute and relative difference; they do not incorporate application-specific tolerances like gear backlash or signal quantization. Finally, the Explorer does not attempt to detect or warn about near-rational numbers that could lead to catastrophic coincidences in control systems. Always sanity-check convergents in the context of your project. Nevertheless, by making continued fractions explorable and exportable, the tool demystifies a classical technique and keeps it relevant for modern quantitative work.
Generate the continued fraction representation of any real number.
Simplify fractions or calculate addition, subtraction, multiplication, and division with this browser-based fraction calculator. Perfect for students, teachers, and anyone working with ratios.
Decompose simple rational expressions into partial fractions for easier integration.