-
-
Notifications
You must be signed in to change notification settings - Fork 674
Closed
Description
The order of quadratic field with specified embedding is not induced from the order of RR and CC. More precisely we have
sage: K.<sqrt2> = NumberField(x^2 - 2, 'sqrt2', embedding=1.4142)
sage: sqrt2 < 100
False
sage: K.<s> = NumberField(x^3 - 2, 's', embedding=1.26)
sage: s < 100
False
which is not compatible with the order of RR and
sage: K.<i> = 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 comparison with quadratic number field elements #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.<sqrt2> = 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.<s> = 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.<sqrt2> = 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.<s> = 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:
Component: number fields
Keywords: real number field, comparison
Author: Vincent Delecroix
Reviewer: Burcin Erocal, Volker Braun
Merged: sage-5.10.beta4
Issue created by migration from https://trac.sagemath.org/ticket/13213