Hi,
I was recently looking at
http://trac.sagemath.org/sage_trac/ticket/3214which pointed out a bug in taking the gcd of a bunch of rational numbers.
I'm not sure we should even be doing this. Here are some arguments:
1. this behaviour is not documented in gcd?? (it is documented in (1/2).gcd??)
2. according to the (not very useful, I agree) mathematical definition of gcd for QQ (or any field), any nonzero rational number is a gcd of any nonempty set of rational numbers. the current behaviour singles one out in a way that's (I think) not feasible for other fields of fractions (or other localisations)
3. as far as I can tell, the main use for the current behaviour of gcd is to get the common denominator of some rational numbers. If I have to do this, I think "I want the common denominator" not "I want the gcd". This is a one-liner:
lcm([x.denominator() for x in list_of_numbers])
I would be happy to write a function common_denominator() that does this, or (maybe even better) extend the existing denominator() function to accept a list of arguments and return their common denominator. This could work for any ring where the elements have denominators.
I'd like to know what people think about this, and whether people use the current gcd for rational numbers for other purposes than 3.
Best,
Alex
--
Alex Ghitza -- Lecturer in Mathematics -- The University of Melbourne -- Australia --
http://www.ms.unimelb.edu.au/~aghitza/