Approximating Rational Numbers by Fractions

  • Michal Forišek
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4475)


In this paper we show a polynomial-time algorithm to find the best rational approximation of a given rational number within a given interval. As a special case, we show how to find the best rational number that after evaluating and rounding exactly matches the input number. In both results, “best” means “having the smallest possible denominator”.


Rational Number Continue Fraction Valid Approximation Wolfram Research Naive Algorithm 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Beiler, A.H.: Farey Tails. Ch. 16 in Recreations in the Theory of Numbers: The Queen of Mathematics Entertains. Dover, New York (1966)zbMATHGoogle Scholar
  2. 2.
    Brocot, A.: Calcul des rouages par approximation, nouvelle methode. Revue Chronométrique 6, 186–194 (1860)Google Scholar
  3. 3.
    Farey, J.: On a Curious Property of Vulgar Fractions. London, Edinburgh and Dublin Phil. Mag. 47, 385 (1816)Google Scholar
  4. 4.
    Forišek, M.: IPSC task Exact? Approximate! [accessed January 2007],
  5. 5.
    Graham, R.L., Knuth, D.E., Patashnik, O.: Concrete Mathematics: A Foundation for Computer Science, 2nd edn. Addison-Wesley Professional, London (1994)zbMATHGoogle Scholar
  6. 6.
    Hardy, G.H., Wright, E.M.: Farey Series and a Theorem of Minkowski. In: An Introduction to the Theory of Numbers, 5th edn. ch. 3, pp. 23–37. Clarendon Press, Oxford England (1979)Google Scholar
  7. 7.
    Knuth, D.E.: How Fast Can We Multiply? In: Sec. 4.3.3 in The Art of Computer Programming II, Addison-Wesley Professional, London (1997)Google Scholar
  8. 8.
    The MathWorks, Inc.: MATLAB Function Reference: rat, rats accessed (January 2007)
  9. 9.
    Stern, M.A.: Ueber eine zahlentheoretische Funktion. Journal für die reine und angewandte Mathematik 55, 193–220 (1858)MathSciNetCrossRefGoogle Scholar
  10. 10.
    Wolfram Research, Inc.: Mathematica 5.2 Documentation: Numerical Precision accessed (January 2007),
  11. 11.
    Wolfram Research, Inc.: Mathematica 5.2 Documentation: Rationalize (January 2007), accessed

Copyright information

© Springer Berlin Heidelberg 2007

Authors and Affiliations

  • Michal Forišek
    • 1
  1. 1.Department of Informatics, Faculty of Mathematics, Physics and Informatics, Comenius University, Mlynská dolina, 842 48 BratislavaSlovakia

Personalised recommendations