Re: [sage-devel] Units in Orders

2012-08-13 Thread Marco Streng

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





Re: [sage-devel] Units in Orders

2012-08-12 Thread Rob Beezer


On Saturday, August 11, 2012 1:22:05 PM UTC-7, Marco Streng wrote:

 These outputs look fine to me. See also 
 http://trac.sagemath.org/sage_trac/ticket/11673 


Dear Marco,

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

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 
sage: OK(12) // OK(13) 
12/13

Thanks,
Rob


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





Re: [sage-devel] Units in Orders

2012-08-12 Thread David Roe
 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

 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
 sage: OK(12) // OK(13)
 12/13

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





[sage-devel] Units in Orders

2012-08-11 Thread Rob Beezer
Is this a bug?

First example is from Judson's abstract algebra text.  Note that 
.is_unit() returned True in sage 4.8.

sage: sage: K.x,y = ZZ[sqrt(-3)]; K
Order in Number Field in a with defining polynomial x^2 + 3
sage: four = K(4)
sage: four.is_unit()
False
sage: four^-1
1/4

Second example: all but the last input is basically from the documentation 
of .is_unit().

sage: K.a = NumberField(x^2 - x - 1)
sage: OK = K.ring_of_integers()
sage: u = OK(13)
sage: u.is_unit()
False
sage: u^-1
1/13

Thanks,
Rob

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





Re: [sage-devel] Units in Orders

2012-08-11 Thread Marco Streng
These outputs look fine to me. See also
http://trac.sagemath.org/sage_trac/ticket/11673

2012/8/11 Rob Beezer goo...@beezer.cotse.net:
 Is this a bug?

 First example is from Judson's abstract algebra text.  Note that
 .is_unit() returned True in sage 4.8.

 sage: sage: K.x,y = ZZ[sqrt(-3)]; K
 Order in Number Field in a with defining polynomial x^2 + 3
 sage: four = K(4)
 sage: four.is_unit()
 False
 sage: four^-1
 1/4

 Second example: all but the last input is basically from the documentation
 of .is_unit().

 sage: K.a = NumberField(x^2 - x - 1)
 sage: OK = K.ring_of_integers()
 sage: u = OK(13)
 sage: u.is_unit()
 False
 sage: u^-1
 1/13

 Thanks,
 Rob

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




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