Opened 6 years ago
Closed 6 years ago
#21740 closed defect (invalid)
Powers with rational exponents from QQbar fail
Reported by:  rws  Owned by:  

Priority:  major  Milestone:  sageduplicate/invalid/wontfix 
Component:  number fields  Keywords:  
Cc:  Merged in:  
Authors:  Ralf Stephan  Reviewers:  
Report Upstream:  N/A  Work issues:  
Branch:  u/rws/powers_with_rational_exponents_from_qqbar_fail (Commits, GitHub, GitLab)  Commit:  bcdf0eda6640619524cdad4d5ae1023c883d7f3b 
Dependencies:  Stopgaps: 
Description
sage: 2^(QQbar(1)) ... TypeError: no canonical coercion from Algebraic Field to Rational Field
Change History (9)
comment:1 Changed 6 years ago by
 Branch set to u/rws/powers_with_rational_exponents_from_qqbar_fail
comment:2 Changed 6 years ago by
 Commit set to d3f8911b56c5fa293b99f37371c6e5c511e7d78f
 Status changed from new to needs_review
comment:3 Changed 6 years ago by
The e = QQ(e)
should call _coerce_
first then call the conversion, so _coerce_
shouldn't need to be called again. (We'd also then want e = QQ(e)
to raise the error.)
comment:4 Changed 6 years ago by
 Commit changed from d3f8911b56c5fa293b99f37371c6e5c511e7d78f to bcdf0eda6640619524cdad4d5ae1023c883d7f3b
Branch pushed to git repo; I updated commit sha1. New commits:
bcdf0ed  21740: change order of calls

comment:5 Changed 6 years ago by
You mean, this way?
comment:6 Changed 6 years ago by
If you're going to try conversion anyway, I don't think it makes much sense to try coercion explicitly first. I think it's good custom that if a coercion exists, conversion should agree with it. So, in effect (and possibly even in implementation!), conversion would try a coercion already.
One of the reasons why conversion might not be appropriate here is that, for instance, QQ("2")
works just fine. So, if you use conversion in exponents the following probably would hold:
sage: 2^"2" 4 sage: a=GF(3)(1) sage: 2^a 4
That's a little too lenient to my taste.
comment:7 Changed 6 years ago by
As me and Vincent Delecroix wrote on sagedevel, it is a feature that 2 ^ QQbar(1)
raises an exception.
comment:8 Changed 6 years ago by
 Milestone changed from sage7.5 to sageduplicate/invalid/wontfix
 Status changed from needs_review to positive_review
comment:9 Changed 6 years ago by
 Resolution set to invalid
 Status changed from positive_review to closed
New commits:
21740: catch cases that can be converted to rational