0 < sqrt3 is False in QuadraticField

4 views
Skip to first unread message

slabbe

unread,
Feb 28, 2010, 7:20:40 PM2/28/10
to sage-devel
Hi Sage-devel,

I am currently experiencing some problems when comparing elements of a
QuadraticField. See below.

sage: Q.<sqrt3> = QuadraticField(3)
sage: 0 < sqrt3
False
sage: RR(sqrt3)
1.73205080756888

The operator < and > do not correspond :

sage: sqrt3 > Q.zero()
True
sage: Q.zero() < sqrt3 #not ok
False

Other similar behavior :

sage: -sqrt3 > Q.zero() #not ok
True
sage: -sqrt3 < Q.zero()
False
sage: sqrt3 < Q.zero()
False
sage: sqrt3 < -sqrt3 #not ok
False
sage: sqrt3 > -sqrt3
True
sage: -sqrt3 > sqrt3 #not ok
True
sage: -sqrt3 < sqrt3
False

Is this known?

Sébastien Labbé

Florent Hivert

unread,
Mar 1, 2010, 3:45:08 AM3/1/10
to sage-...@googlegroups.com
Hi Sebastien,

> I am currently experiencing some problems when comparing elements of a
> QuadraticField. See below.

I'm not sure this is exactly the same but I think Nicolas (the little) is
working on this:

Ticket #8347 Test the positivity of a number field element

Florent

Robert Bradshaw

unread,
Mar 1, 2010, 2:10:49 PM3/1/10
to sage-...@googlegroups.com
On Feb 28, 2010, at 4:20 PM, slabbe wrote:

> Hi Sage-devel,
>
> I am currently experiencing some problems when comparing elements of a
> QuadraticField. See below.
>
> sage: Q.<sqrt3> = QuadraticField(3)
> sage: 0 < sqrt3
> False
> sage: RR(sqrt3)
> 1.73205080756888

[...]

> Is this known?

Yes, cmp() for number field elements is arbitrary, as they don't have
(canonical) real embeddings in general. There are a couple of tickets
to address this.

- Robert

Dima Pasechnik

unread,
Mar 1, 2010, 10:21:48 PM3/1/10
to sage-devel

On Mar 2, 3:10 am, Robert Bradshaw <rober...@math.washington.edu>
wrote:

But for the QuadraticField this is unique, if the embedding is
specified:
sage: QuadraticField?
....
Unless otherwise specified, it has an embedding into RR or CC
by sending
the generator to the positive root.
....

So if should be working, if the documentation does not lie....

Dima

>
> - Robert

Reply all
Reply to author
Forward
0 new messages