id,summary,reporter,owner,description,type,status,priority,milestone,component,resolution,keywords,cc,merged,author,reviewer,upstream,work_issues,branch,commit,dependencies,stopgaps
13213,Comparisons in quadratic number field,vdelecroix,vdelecroix,"The order of quadratic field with specified embedding is not induced from the order of RR and CC. More precisely we have
{{{
sage: K. = NumberField(x^2 - 2, 'sqrt2', embedding=1.4142)
sage: sqrt2 < 100
False
sage: K.~~ = NumberField(x^3 - 2, 's', embedding=1.26)
sage: s < 100
False
}}}
which is not compatible with the order of RR and
{{{
sage: K.~~* = QuadraticField(-1)
sage: i > 1
True
sage: 1 > i
True
}}}
which is not compatible (!) with the order of CC.
The ticket implements the order for quadratic field (for which comparisons are made using only operations on integers).
Note:
* this patch is partly a duplicate because of #7160
* the modifications for quadratic field field modify the behavior of many commands (especially about output order).
* the patch introduces a new attribute to NumberFieldElement_quadratic called standard_embedding (of type bint)
----
There is no significant lost of speed as shown on the following timings.
{{{
sage: K. = QuadraticField(2, 'sqrt2', embedding=1.4142)
sage: a = (3*sqrt2 + 18)/7
sage: b = (5*sqrt2 + 14)/5
sage: %timeit a < b
1000000 loops, best of 3: 408 ns per loop
sage: K.*~~ = QuadraticField(-2)
sage: a = 3*s + 2/4
sage: b = 5/7*s + 1/3
sage: %timeit a < b
1000000 loops, best of 3: 352 ns per loop
}}}
Timings without the patch
{{{
sage: sage: K. = QuadraticField(2,'sqrt2',embedding=1.4142)
sage: a = (3*sqrt2 + 18)/7
sage: b = (5*sqrt2 + 14)/5
sage: %timeit a < b
1000000 loops, best of 3: 393 ns per loop
sage: K.~~~~ = QuadraticField(-2)
sage: a = 3*s+2/4
sage: b = 5/7*s+1/3
sage: %timeit a < b
1000000 loops, best of 3: 344 ns per loop
}}}
Apply:
* [attachment:trac_13213-quadratic_field_comparison.patch]",enhancement,closed,major,sage-5.10,number fields,fixed,"real number field, comparison",,sage-5.10.beta4,Vincent Delecroix,"Burcin Erocal, Volker Braun",N/A,,,,,
~~