<br><br><div class="gmail_quote">2009/8/4 Chongkai Zhu <span dir="ltr"><<a href="mailto:czhu@cs.utah.edu">czhu@cs.utah.edu</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I just checked both r5rs and r6rs. Their definition of "/simplest/ rational number" is more complex than it can be. Here's PLT's (and another system's) doc of rationalize:<br>
<br>
----<br>
(rationalize x tolerance) ? real?<br>
x : real?<br>
tolerance : real?<br>
<br>
Among the real numbers within (abs tolerance) of x, returns the one corresponding to an exact number whose denominator is smallest. If multiple integers are within tolerance of x, the one closest to 0 is used.<br>
<br>
----<br>
<br>
rationalize(x,dx)<br>
yields the rational number with smallest denominator that lies within dx of x.<br>
<br>
----<br>
<br>
in which you can see only to make the denominator smallest is enough. Is this enough hint for you to come to an algorithm?</blockquote><div><br>That's certainly enough of a simplification to give me an idea, though I'm not sure it'll be very efficient. I'll try to implement it and post here for feedback.<br>
<br>James <br></div></div><br>