Opened 4 years ago
Closed 3 years ago
#18819 closed defect (fixed)
Real number fields with __cmp__ that gives a linear order induced by its real embedding
Reported by: | mkoeppe | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | number fields | Keywords: | |
Cc: | vbraun, gagern, vdelecroix | Merged in: | |
Authors: | Reviewers: | ||
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
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
Change History (6)
comment:1 follow-up: ↓ 2 Changed 4 years ago by
comment:2 in reply to: ↑ 1 Changed 4 years ago by
Replying to vdelecroix:
Duplicate of #17830?
Indeed. Not sure how I managed to overlook this ticket.
comment:3 Changed 4 years ago by
- Milestone changed from sage-6.8 to sage-duplicate/invalid/wontfix
comment:4 Changed 4 years ago by
- Status changed from new to needs_review
Setting this to "needs_review" so that this ticket can be closed.
comment:5 Changed 4 years ago by
- Status changed from needs_review to positive_review
comment:6 Changed 3 years ago by
- Resolution set to fixed
- Status changed from positive_review to closed
Duplicate of #17830?