On 13/08/2012 06:50, David Roe wrote:
Thanks for the pointer to that ticket, which explains the change in the the
"is_unit()" behavior.

Why should the inverse of "four" succeed when the result is not in K?

sage: four^-1 in K
False
The order K is analogous to the ring of integers inside QQ.  So even
though the inverse of four exists in the number field, it's not in the
order and thus four is not a unit.  See
http://en.wikipedia.org/wiki/Order_%28ring_theory%29

Exactly. This is completely analogous to the following:

sage: 4.parent() is ZZ
True
sage: 4.is_unit()
False
sage: 4^-1
1/4
sage: 4^-1 in ZZ
False
sage: (4^-1).parent() is QQ
True

In your example, ZZ is replaced with the order K, and QQ is replaced by the field of fractions of K, which is the number field QQ(sqrt(-3)).


On #12242 (a follow-on to the ticket above), David Loeffler argues that the
following is the wrong behavior, and that the last command should raise an
error.

sage: K.<a> = NumberField(x^2 - x - 1); OK = K.ring_of_integers()
sage: OK(12).divides(OK(13))
True

Here again OK is a generalization of ZZ.

In K, 12 does divide 13 and the quotient is 13/12, but since 13/12 is not in OK, the answer should be False as David says.

sage: OK(12) // OK(13)
12/13

Since OK is a generalization of ZZ, we look at what "//" does for ZZ. From the reference manual, http://www.sagemath.org/doc/tutorial/tour_assignment.html :

sage:10//4    #  for integer arguments, // returns the integer quotient
2


So "//" gives the integral part of the quotient, forgetting the remainder. Just like "/" does for python ints. Therefore,

sage: 12//13
0
sage: (12//13).parent() is ZZ
True

So whatever "OK(12) // OK(13)" returns, it has to be an element of OK, hence (as David L. says: not 12/13). Moreover, we must always have b * (a // b) + (a % b) == a for this quotient and remainder. The easiest fix is have it raise an Error, which is better than anything that is not in OK.

Again, it's a question of where the arithmetic is taking place.  The
issue is that 12/13, while an element of K, is not in OK.
David



--
--
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