[issue1682] Move Demo/classes/Rat.py to Lib/rational.py and fix it up.

Mark Dickinson report at bugs.python.org
Sat Jan 12 02:47:46 CET 2008


Mark Dickinson added the comment:

About .trim and .approximate:  

it sounds like these are different, but quite closely related, methods:  one takes a positive 
integer and returns the best approximation with denominator bounded by that integer;  the other 
returns the 'smallest' rational in a given interval centered at the original rational.  I guess 
we probably don't need both of these, but I can't give any good reason for preferring one over 
the other.

I don't have anything to offer about names, either.

I can try to find out whether the algorithms are published anywhere on the web---certainly, 
neither algorithm should be particularly hard to implement and prove the correctness of;  they 
both essentially rely on computing the continued fraction development of the given rational.  
Almost any not-too-basic elementary number theory text should contain proofs of the relevant 
results about continued fractions.

Am willing to help out with implementing either of these, if that's at all useful.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1682>
__________________________________


More information about the Python-bugs-list mailing list