[racket-dev] feature request: gcd, lcm for rationals

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sat Dec 10 04:23:59 EST 2011

2011/12/10 Stephen Bloch <sbloch at adelphi.edu>

> On Dec 9, 2011, at 3:31 PM, Daniel King wrote:
> > On Fri, Dec 9, 2011 at 15:27, Carl Eastlund <cce at ccs.neu.edu> wrote:
> >> What does "divides" even mean in Q?  I think we need David to explain
> >> what his extension of GCD and LCM means here, in that "divisors" and
> >> "multiples" are fairly trivial things in Q.
> >
> > I don't suppose to understand all the math on this page, but I think
> > it uses the same definition that dvh is using.
> >
> > http://mathworld.wolfram.com/GreatestCommonDivisor.html
> Interesting: the Mathematica people have extended the gcd function from
> the integers to the rationals, not by applying the usual definition of gcd
> to Q (which would indeed be silly, as everything except 0 divides
> everything else), but by coming up with a different definition which, when
> restricted to integers, happens to coincide with the usual definition of
> gcd.

If we for rational numbers x and y define "x divides y" to mean "y/x is an
then I believe the definition
      d is a gcd of x and y
 <=> i) d divides a and y
        ii) e divides x and y => d divides e
coincides with the MathWorld definition.

> I would wonder: is this the ONLY "reasonable" function on rationals which,
> when restricted to integers, coincides with the usual definition of gcd?

Not sure, but this seems relevant.


Jens Axel Søgaard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20111210/75333269/attachment.html>

Posted on the dev mailing list.