#25218 closed enhancement (fixed)
Extract roots in NumberField if possible
Reported by:  ghBrentBaccala  Owned by:  

Priority:  minor  Milestone:  sage8.3 
Component:  algebra  Keywords:  NumberField 
Cc:  slelievre  Merged in:  
Authors:  Brent Baccala  Reviewers:  Sébastien Labbé 
Report Upstream:  N/A  Work issues:  
Branch:  17b93d6 (Commits, GitHub, GitLab)  Commit:  
Dependencies:  Stopgaps: 
Description
NumberField previously evaluated integral powers in the NumberField, and evaluated all fractional powers in the symbolic ring.
This patch makes NumberField attempt to evaluate the fractional power within the field, and only falls back on the symbolic ring if this fails.
There's a few interesting changes in the test suite.
Old code:
sage: QQbar((2*I)^(1/2)) 1 + 1*I sage: (2*I)^(1/2) sqrt(2*I) sage: I^(2/3) I^(2/3)
New code:
sage: QQbar((2*I)^(1/2)) I + 1 sage: (2*I)^(1/2) I + 1 sage: I^(2/3) 1
The first change is just cosmetic. The second makes good sense, as Sage is now evaluating an expression it didn't before. The third change is more troubling.
The explanation lies in the definition of I:
sage: I.parent() Symbolic Ring sage: I.pyobject().parent() Number Field in I with defining polynomial x^2 + 1
In this number field, there is a single cube root of I
(I
). Squaring I
gives us 1
, so I^(2/3)=1
.
My opinion is that the new behavior of NumberField is correct and preferred, but perhaps I
should be defined in QQbar, not in a NumberField.
Change History (10)
comment:1 Changed 4 years ago by
 Branch set to u/ghBrentBaccala/25218
 Commit set to 087174bfe499b07ed66ea60c4f6eb2c9a0aee7a3
comment:2 Changed 4 years ago by
 Cc slelievre added
Regarding the suggestion that
perhaps
I
should be defined in QQbar, not in a NumberField,
see also #18036.
comment:3 Changed 4 years ago by
The following tickets are possibly related.
 #7545: Gaussian and Eisenstein integers https://trac.sagemath.org/ticket/7545
 #18036: I.parent() should not be the symbolic ring https://trac.sagemath.org/ticket/18036
 #22208: Conversion from SR to number fields https://trac.sagemath.org/ticket/22208
 #25178: SR('I') is not consistent https://trac.sagemath.org/ticket/25178
 #25218: Extract roots in NumberField if possible https://trac.sagemath.org/ticket/25218
comment:4 Changed 4 years ago by
 Commit changed from 087174bfe499b07ed66ea60c4f6eb2c9a0aee7a3 to 592e263482a364ed1987db67aa41c6f2897b8e95
Branch pushed to git repo; I updated commit sha1. New commits:
592e263  Trac #25218: fix typo

comment:5 Changed 4 years ago by
 Status changed from new to needs_review
comment:6 Changed 4 years ago by
 Branch changed from u/ghBrentBaccala/25218 to u/slabbe/25218
 Commit changed from 592e263482a364ed1987db67aa41c6f2897b8e95 to 17b93d604a5c2d45a136d171db513681a320f58f
 Reviewers set to Sébastien Labbé
I did small spaces fixes. If you agree with my changes, please change the status to positive review.
New commits:
17b93d6  25218: space fixes

comment:7 Changed 4 years ago by
 Status changed from needs_review to positive_review
comment:8 Changed 4 years ago by
 Milestone changed from sage8.2 to sage8.3
comment:9 Changed 4 years ago by
 Branch changed from u/slabbe/25218 to 17b93d604a5c2d45a136d171db513681a320f58f
 Resolution set to fixed
 Status changed from positive_review to closed
comment:10 in reply to: ↑ description Changed 19 months ago by
 Commit 17b93d604a5c2d45a136d171db513681a320f58f deleted
Replying to ghBrentBaccala:
The third change is more troubling.
The explanation lies in the definition of I:
sage: I.parent() Symbolic Ring sage: I.pyobject().parent() Number Field in I with defining polynomial x^2 + 1In this number field, there is a single cube root of
I
(I
). SquaringI
gives us1
, soI^(2/3)=1
.My opinion is that the new behavior of NumberField is correct and preferred, but perhaps
I
should be defined in QQbar, not in a NumberField.
I think this is very unfortunate. In Sage, QQ[i] automatically comes with a complex embedding, for which i^{2/3} (= exp(iπ/3)) is perfectly well defined. It is really confusing to have a basic operator like ^
(whose evaluation normally uses the coercion framework) that is incompatible with the embedding.
See #30783.
New commits:
Trac #25218: NumberField attempts to evaluate fractional powers
Trac #25218: update test cases altered by this patch