PS:

On 9 Feb., 15:57, luisfe <lftab...@yahoo.es> wrote:
> There is also something wrong with lcm for rationals
>
> sage: a = 2/3 # rational
> sage: b = 1    # integer
> sage: gcd(a,b)
> 1
> sage: lcm(a,b)
> ...
> TypeError

I would agree that this is a bug. I think it would be just consequent
to first coerce a and b before computing their gcd or lcm.


> Also, I am little surprised about the definition of lcm here. I would
> expect, maybe naively, that the lcm of 1/3 and 1/2 is 1/6. That is:
> lcm(numerators) / lcm(denominators)
> Although the current behavior is well documented. Thinking a little
> bit the lcm seems to be defined as the smallest 'integer' multiple of
> 1/3 and 1/2. The generator of the intersection of the ZZ-modules
> ZZ[1/3] and ZZ[1/2]. So it makes sense...

Ah, yet another definition with yet another answer for the rationals.
So, now we have at least six different ways to extend the common
notion of lcm from ZZ to QQ:

lcm(1/4,1/6) = 0      (infimum over positive multiples)

lcm(1/4,1/6) = 1/4   (infimum over positive multiples with factor at
least one)

lcm(1/4,1/6) = 1/12 (lcm(numerators) / lcm(denominators))

lcm(1/4,1/6) = 1/2   (infimum over positive multiples with integer
factor)

lcm(1/4,1/6) = 1      (minimal positive multiple that is an integer)

lcm(1/4,1/6) = 1/2   (lcm(numerators)/gcd(denominators))

... [add further definitions here]

Tough choice!
At least, the last one has the property gcd(x,y)*lcm(x,y)==x*y,
assuming that we also define gcd(a/b,c/d) = gcd(a,c)/lcm(b,d).

I agree with Richard Fateman that in this case one shouldn't simply
decide by counting "+1" (isn't there a board for that purpose?).
But I think the problem here is not coercion but the "right" (or at
least reasonable) choice of a definition. What would textbooks say?

Cheers,
Simon

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to