> sage seems to think that the gcd of 6 and (-2 mod 6) is -2 mod 6, which it 
> converts to 4.  A mathematician would say that the gcd is 2.
> Is this a bug, or does sage have a higher purpose here?

Sage is actually reasoning slightly differently, I think.  First it
decides whether there's a canonical coercion to a common parent.  In
this case, it concludes that the common parent should be the ring of
integers modulo 6:

sage: parent(Mod(4,6))
Ring of integers modulo 6
sage: parent(6)
Integer Ring
sage: z = cm.canonical_coercion(Mod(4,6), 6)
sage: z
(4, 0)
sage: parent(z[0]), parent(z[1])
(Ring of integers modulo 6, Ring of integers modulo 6)

There's no gcd method defined in this ring, so it falls back to
attempting to coerce 4 mod 6 and 0 mod 6 to ZZ, which succeeds, and we
get the integer version under which we have

sage: gcd(4,0)
4

It's not clear to me what the best way to handle this case is.  Paging
Simon King.. :^)


Doug

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

Reply via email to