#18819: Real number fields with __cmp__ that gives a linear order induced by its
real embedding
-----------------------------+----------------------------
   Reporter:  mkoeppe        |            Owner:
       Type:  defect         |           Status:  new
   Priority:  major          |        Milestone:  sage-6.8
  Component:  number fields  |         Keywords:
  Merged in:                 |          Authors:
  Reviewers:                 |  Report Upstream:  N/A
Work issues:                 |           Branch:
     Commit:                 |     Dependencies:
   Stopgaps:                 |
-----------------------------+----------------------------
 It would seem to be useful to have a category of number fields whose
 `__cmp__` method agrees with the linear order of its embedding. (I might
 be using the word "category" in a non-technical sense.)

 This has been the topic of past discussions and tickets (#6132, #7160,
 #9752),
 and there is a conflict between at least two different desirable meanings
 for `__cmp__`, which could be
  - lexicographic comparison of the coordinates in the power basis of the
 generator;
  - or, as proposed, the linear order.
 But it has not been completely resolved. The current status in Sage is
 inconsistent because quadratic number fields behave differently from
 number fields of a higher degree, due to
 `NumberFieldElement_quadratic.__cmp__`.

 {{{
 sage: field, field_values, morphism =
 number_field_elements_from_algebraics((sqrt(2), sqrt(3)))
 sage: field_values
 [-a^3 + 3*a, -a^2 + 2]
 # If I explicitly send the number field elements back into AA, I can
 compare them
 sage: 1 < morphism(field_values[0]) < morphism(field_values[1]) < 2 < 3 *
 morphism(field_values[0]) < 5
 True
 # but the number field elements themselves do not compare according to
 that linear order.
 sage: field_values[0] < field_values[1]
 False

 # and note that this is in contrast to the special case of quadratic
 # extensions of the rationals, where comparisons seem to work as
 # expected.
 sage: from sage.rings.number_field.number_field_element_quadratic import
 NumberFieldElement_quadratic
 K.<sqrt2> = QuadraticField(2,name='sqrt2')

 sage: 1 < sqrt2 < 2 < 3 * sqrt2 < 5
 True
 }}}

 (I mentioned this to some developers during the Sage Days in Davis in
 2013, but didn't follow up on it.)

 An implementation of this in user code is brittle as it will depend on
 Sage internals. This is what I'm currently doing for my application:
 https://github.com/mkoeppe/infinite-group-relaxation-
 code/blob/master/real_number_field.sage

--
Ticket URL: <http://trac.sagemath.org/ticket/18819>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to