Ask Your Question

Revision history [back]

Comparing numbers in an algebraic field

I get a very strange results from comparison of number in an algebraic field, see the example:

version()
X = polygen(ZZ)
f = X^3 - 2*X^2 - 2*X - 2
Qb.<b> = QQ.extension(f, embedding=3)

b.N() # b is positive
0 < b # gives False; why?
0 < 1 # gives True; fine
Qb(0) < Qb(1) # gives False; WTF?

sage: version()
'Sage Version 6.1.1, Release Date: 2014-02-04'
sage: X = polygen(ZZ)
sage: f = X^3 - 2*X^2 - 2*X - 2
sage: Qb.<b> = QQ.extension(f, embedding=3)
sage: 
sage: b.N() # b is positive
2.91963956583942
sage: 0 < b # gives False; why?
False
sage: 0 < 1 # gives True; fine
True
sage: Qb(0) < Qb(1) # gives False; WTF?
False
sage:

Can I do something to obtain the correct results of comparison, or is using the flawed .N() the only option?

click to hide/show revision 2
retagged

Comparing numbers in an algebraic field

I get a very strange results from comparison of number in an algebraic field, see the example:

version()
X = polygen(ZZ)
f = X^3 - 2*X^2 - 2*X - 2
Qb.<b> = QQ.extension(f, embedding=3)

b.N() # b is positive
0 < b # gives False; why?
0 < 1 # gives True; fine
Qb(0) < Qb(1) # gives False; WTF?

sage: version()
'Sage Version 6.1.1, Release Date: 2014-02-04'
sage: X = polygen(ZZ)
sage: f = X^3 - 2*X^2 - 2*X - 2
sage: Qb.<b> = QQ.extension(f, embedding=3)
sage: 
sage: b.N() # b is positive
2.91963956583942
sage: 0 < b # gives False; why?
False
sage: 0 < 1 # gives True; fine
True
sage: Qb(0) < Qb(1) # gives False; WTF?
False
sage:

Can I do something to obtain the correct results of comparison, or is using the flawed .N() the only option?