A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-January/076319.html below:

[Python-Dev] Rational approximation methods

[Python-Dev] Rational approximation methods [Python-Dev] Rational approximation methodsScott David Daniels Scott.Daniels at Acm.Org
Sat Jan 19 23:35:50 CET 2008
Jeffrey Yasskin wrote:
> The second returns the simplest rational within some distance. For
> instance, it'll prefer 22/7 over 333/106 if both are close enough. We
> might call it .simplest_within() for now. This seems useful for
> converting from float and displaying results to users, where we prefer
> readability over accuracy or have reason to believe that a simpler
> fraction might be more correct.
You can use a mediant walk to get to two surrounding fractions w/ some
limit, and then return the pair to let the caller choose.

See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52317
for an imperfect implementation.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4