I agree that this functionality should be given a different name so we can keep gcd for genuine gcds.
Alex, your definition of common denominator is not exactly the same as the denominator of the gcd. I think a more useful function which would apply to the field of fractions of any PID would be content(), i.e. the content of [q_1,q_2,...,q_n] is the unique positive rational c such that the q_i/c are coprime integers. This is precisely what gcd() currently gives on a list of rationals. For a list L of integers, L.content() is just L.gcd(). The content() function can also apply to things like polynomials. By the way, sage-nt might have been a better place for this discussion? John 2008/12/30 Alex Ghitza <aghi...@gmail.com>: > Hi, > > I was recently looking at > http://trac.sagemath.org/sage_trac/ticket/3214 > which 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/ > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---