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

From: Marijn (hkBst at gentoo.org)
Date: Wed Dec 14 05:11:31 EST 2011

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09-12-11 20:04, Jens Axel Søgaard wrote:
> One definition of greatest common divisor in a ring R is: d is a
> greatest common divisor of x and y when: i)  d divides both x and
> y ii)  If e is a divisor of both x and y, then d divides e

I think you mixed up ii) here since to get the _greatest_ common
divisor it makes more sense if any other common divisor divides the
greatest instead of the other way around.

> Now let's consider the ring Q. Since Q is a field, 1 divides all
> elements.

Since Q is a field any non-zero element a divides any element b: a *
b/a = b. And all such non-zero divisors divide each other by the same
token.

> It is therefore not obvious that gcd should be extendend as you
> suggest.

Indeed. The definition seems plausible at a first glance:

> (gcd-rational 2/3 2/3)
2/3
> (lcm-rational 2/3 2/3)
2/3

but what about:

> (gcd-rational 2/3 2/3 2/3)
2/3
> (lcm-rational 2/3 2/3 2/3)
4/9

is that 4/9 the intended result?

Marijn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk7odlMACgkQp/VmCx0OL2xJXgCfRhnUR/GXHs4PoMhVWGGkqdC2
95UAoKGN3/SigQDq5mPX+NO9dzj5Ox+S
=n0HH
-----END PGP SIGNATURE-----


Posted on the dev mailing list.