Continued Fraction Convergent Explorer
Introduction: exploring continued-fraction convergents
Continued fractions provide a systematic route from a real number to useful rational approximations. This explorer lets you enter a decimal, a simple fraction, or a supported constant and then inspect the fractions produced by its simple continued fraction. Each row records one convergent: its partial quotient, numerator, denominator, decimal approximation, and two measures of the difference from the target. That makes the progression visible instead of treating a familiar fraction such as 22/7 as an isolated trick.
Start by choosing the number whose rational form matters for your problem. You can paste a decimal, enter a fraction such as 355/113, or use supported names including pi, e, phi, and square-root expressions such as sqrt(2). After parsing the target, the calculator applies the Euclidean-style continued-fraction process to obtain partial quotients and constructs a sequence of convergents. Numerators and denominators can grow quickly, while the approximation error often falls much faster. A small-denominator fraction appearing near a long decimal is the practical payoff of the calculation.
From partial quotients to continued-fraction convergents
For continued-fraction convergents, the calculator uses the standard recurrence for the partial quotients of a simple continued fraction. If the target supplies partial quotients a0, a1, …, an, the numerator pn and denominator qn of the next convergent are calculated from the preceding two numerator-denominator pairs.
In continued-fraction terms, each new numerator is the current partial quotient times the previous numerator, plus the numerator before it; denominators follow the identical pattern. The code keeps the two earlier terms for exactly this reason. It stops when a rational target has no fractional remainder or when the maximum depth is reached. The absolute error is the distance between the target and the displayed fraction. Relative error divides that distance by the target’s magnitude and expresses it as a percentage, except that the calculator reports zero relative error for a zero target.
Worked example: continued-fraction approximations to √2
To explore continued-fraction convergents for the square root of two, enter “sqrt(2),” set the maximum depth to 10, and use an absolute-error tolerance of 10−6. The table starts with 1/1 and 3/2, then continues through 7/5, 17/12, 41/29, 99/70, and 239/169. These rows show how the fractions alternate around √2 while their errors decrease. At this depth, 1393/985 is the first listed convergent whose absolute error is below 10−6, so the summary identifies it as meeting that tolerance.
The point of the √2 calculation is not merely to reproduce a decimal expansion. Continued fractions generate candidate fractions with denominators that arise from the target’s partial quotients, rather than selecting a denominator first and rounding afterward. If a physical design, tuning ratio, or discrete component choice limits the denominator, compare the denominator column with the absolute-error column and choose a row appropriate to that constraint. The calculator does not know the acceptable engineering or measurement error for your application, so the tolerance and the final choice remain yours.
Comparing continued-fraction target numbers
Continued-fraction behavior differs substantially from one target number to another. Try π, e, and a measured decimal in separate calculations, then compare the partial quotients, denominator growth, and error columns rather than assuming that every constant will yield a compact approximation at the same depth.
| Target | Useful table feature | Denominator check | Error check |
|---|---|---|---|
| π | Look for familiar small fractions | Compare size with available resolution | Read the absolute error for the chosen row |
| e | Inspect the sequence of partial quotients | Note how quickly denominators increase | Compare successive error reductions |
| A measured decimal | Check whether a simple fraction appears early | Match the denominator to the practical limit | Use the stated tolerance for acceptance |
For continued-fraction exploration, the most useful comparison is usually local: determine which row is the first to satisfy your error limit and whether its denominator is usable. A target can have an unusually effective low-denominator convergent, while another may require much larger numerator and denominator values before its error becomes small. Running the same depth and display precision for several targets makes those differences easier to see without treating a rounded decimal as proof that two approximations are equally suitable.
Understanding continued-fraction error metrics
The continued-fraction table’s absolute and relative error columns describe the difference between each convergent and the parsed target value. Absolute error is |target − convergent|, so it uses the numerical scale of the value entered. Relative error is that absolute error divided by the absolute target value and multiplied by 100. The latter is useful when comparing targets of very different magnitudes, while absolute error is normally the more direct test when the form specifies an absolute-error tolerance.
Read both columns with the source of the target in mind. If the target was itself rounded, a convergent may be extremely close to the rounded JavaScript value without representing a uniquely meaningful fraction for the original measurement. Conversely, a fraction with a slightly larger error may be preferable when its denominator is easier to implement or communicate. The decimal-places setting changes how decimal approximations are displayed, not the convergents or the errors used by the calculation.
Putting the convergent CSV download to work
After computing continued-fraction convergents, the Download Convergent CSV button saves the table currently generated by the calculator. The file contains the index, partial quotient, numerator, denominator, decimal approximation, absolute error, and relative error percentage. This is useful when you want to compare several target values in a spreadsheet, preserve the fractions used in a calculation, or graph how the reported error changes across the generated sequence.
The CSV reflects the current maximum depth and decimal-display setting. Its decimal approximation column is formatted to the selected number of decimal places, whereas the error fields are written from the computed values. If you use the file in a design, classroom, or research workflow, retain the original target entry and settings alongside it so another reader can reproduce the same continued-fraction table.
Formula: continued-fraction convergents for rational approximation
Continued-fraction convergents are valuable whenever a real-valued ratio must be represented by manageable integers. A scale model, musical interval, sampling ratio, or measured proportion may call for a fraction whose denominator is limited by available parts or resolution. Entering the underlying value into this explorer produces an ordered sequence of rational candidates, so you can weigh simplicity against closeness instead of testing unrelated fractions one at a time.
The calculator is also a compact way to study number theory. Use a rational input to observe that the sequence terminates, then compare it with an irrational input that continues until the depth cap. Examine the partial quotients alongside the numerator and denominator recurrence to connect the arithmetic procedure with the resulting fractions. The table reports approximations; it does not decide which denominator, tolerance, or application model is appropriate.
Limitations and assumptions for continued-fraction convergents
This continued-fraction explorer uses JavaScript double-precision floating-point arithmetic. Very deep expansions or targets near floating-point precision can therefore reflect rounding in the parsed value and in later remainder calculations. The form limits computation to 30 convergents, and the displayed decimal approximation is limited to the selected number of decimal places. Those limits are appropriate for inspecting ordinary numerical inputs but are not a substitute for arbitrary-precision symbolic computation.
The target parser accepts decimals, simple fractions, the listed constants, and square-root forms with a non-negative numeric argument; it does not evaluate general symbolic expressions. Error values compare each fraction with the parsed numerical target, not with an independently exact symbolic value. Finally, a small numerical error does not automatically establish that a fraction is suitable for a physical, financial, cryptographic, or scientific task. Check the denominator constraint, input precision, and real-world tolerance before relying on a convergent outside a mathematical exercise.
Arcade Mini-Game: Continued Fraction Convergent Explorer Calibration Run
Use this quick arcade run to practice separating useful scenario inputs from common planning mistakes before you rely on the calculator output.
Start the game, then use your pointer or arrow keys to catch useful inputs and avoid bad assumptions.
| Index | Partial quotient | Numerator | Denominator | Decimal approximation | Absolute error | Relative error (%) |
|---|
