Best Rational Approximation Calculator
Find closest rational to supplied binary floating-point value over denominators 1..caller bound, with earliest denominator ties; unlike continued fractions, checks global finite denominator inventory, not irrationality proof.
Description
A bounded rational approximation searches for the closest fraction to a supplied floating-point value.
A bounded rational approximation searches for the closest fraction to a supplied floating-point value. The denominator limit defines a finite optimization problem.1
Find closest rational to supplied binary floating-point value over denominators 1..caller bound, with earliest denominator ties; unlike continued fractions, checks global finite denominator inventory, not irrationality proof.
When to use Best Rational Approximation Calculator
Use this tool to find closest rational to supplied binary floating-point value over denominators 1..caller bound, with earliest denominator ties; unlike continued fractions, checks global finite denominator inventory, not irrationality proof.
Choose the integer, sequence, coefficients or function parameters for your calculation. Follow the stated ordering, domain and size limits.
How to use Best Rational Approximation Calculator and understand its results
- Choose the integer, sequence, coefficients or function parameters for your calculation. Follow the stated ordering, domain and size limits.
- Enter realValue, maximumDenominator using the field table and calculation rules, then run the tool.
- Read bestNumerator, bestDenominator, absoluteApproximationError. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| realValue | Real value | number | Required |
| maximumDenominator | Maximum denominator | number | Required |
Use integer maximum denominator 1–100,000 and a finite real value satisfying |x|×limit≤MAX_SAFE_INTEGER/2. Compare every denominator, retaining the earliest on exact error ties. Return numerator, denominator and absolute error.
for each q=1..limit, choose p=round(xq); minimize |x−p/q| Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| bestNumerator | Best numerator | number |
| bestDenominator | Best denominator | number |
| absoluteApproximationError | Absolute approximation error | number |
{
"input": {
"realValue": 3.141592653589793,
"maximumDenominator": 10
},
"output": {
"bestNumerator": 22,
"bestDenominator": 7,
"absoluteApproximationError": 0.0012644892673496777
}
} Limitations and assumptions
The target is the supplied binary floating-point number. The search does not prove irrationality or identify an exact symbolic value.
Numeric inputs and returned numeric values must be finite; an unrepresentable returned value produces an error. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use Padé Approximant Calculator: Solve bounded [m/n] Padé approximant from exactly m+n+1 caller Taylor coefficients, denominator constant one; singular/unresolved systems refused rather than invent a unique approximation. For a complementary task, use Lambert W Newton Approximation: Approximate either real Lambert W branch with safeguarded Newton/bisection and explicit equation residual; lower branch only on [−1/e,0), no complex continuation or false unique root.
References
-
Best Rational Approximation Calculator — tool.io
Similar or alternative tools
- Padé Approximant Calculator
Solve bounded [m/n] Padé approximant from exactly m+n+1 caller Taylor coefficients, denominator constant one; singular/unresolved systems refused rather than invent a unique approximation.
- Lambert W Newton Approximation
Approximate either real Lambert W branch with safeguarded Newton/bisection and explicit equation residual; lower branch only on [−1/e,0), no complex continuation or false unique root.