#30783 closed defect (fixed)

Sage thinks that I^(2/3) = -1

Reported by: mmezzarobba Owned by:
Priority: major Milestone: sage-9.3
Component: basic arithmetic Keywords:
Cc: gh-BrentBaccala Merged in:
Authors: Marc Mezzarobba Reviewers: Sébastien Labbé
Report Upstream: N/A Work issues:
Branch: 0807787 (Commits, GitHub, GitLab) Commit: 080778741065560bdce8be7a4c207e97ab0163d4
Dependencies: Stopgaps:

Status badges

Description (last modified by mmezzarobba)

Revert #25218.

Rationale: #25218 makes a^(p/q) where a is a number field element attempt to return a solution to a^p = x^q in the number field. This makes powering inconsistent with coercions, since number fields often (and, in the case of quadratic fields, automatically) come with a complex embedding and complex numbers of various kinds use the principal branch of the power function.

Among other confusing behaviors, we have

sage: I^(2/3)
I^(2/3)
sage: QQbar(I^(2/3))
0.500000000000000? + 0.866025403784439?*I
sage: QQbar(I)^(2/3)
0.500000000000000? + 0.866025403784439?*I

but

sage: I.pyobject()^(2/3)
-1

and

sage: QQi.<i> = QuadraticField(-1)
sage: i^(2/3)
-1

but

sage: QQbar(i)^(2/3)
0.500000000000000? + 0.866025403784439?*I

as well as

sage: CC((i^(1/6))^2)
0.866025403784439 + 0.500000000000000*I
sage: CC((i^(1/3)))
-1.00000000000000*I
sage: i^(1/3)*CC(i)^(1/3)
0.500000000000000 - 0.866025403784439*I

Change History (8)

comment:1 Changed 21 months ago by tmonteil

Hi Marc, could you please provide more details about this ticket ? Currently (9.2.rc2), we have:

sage: I^(2/3)                                                                                                                                                                                                
I^(2/3)
sage: _.n()                                                                                                                                                                                                  
0.500000000000000 + 0.866025403784439*I

comment:2 Changed 21 months ago by mmezzarobba

Sorry, I didn't have time yesterday. This happens for i ∈ ℚ[i], not i ∈ SR (see the linked ticket). But note that #18036 aims to make the glbal symbol i refer to the generator of ℚ[i]. (In fact, I am currently trying again to make that change, and that's how I discovered the issue.)

comment:3 Changed 21 months ago by slabbe

Oups, I made a mistake while reviewing #25218. Feel free to fix that to the correct thing.

comment:4 Changed 21 months ago by mmezzarobba

  • Authors set to Marc Mezzarobba
  • Branch set to u/mmezzarobba/30783-revert_25218
  • Cc gh-BrentBaccala added
  • Commit set to 080778741065560bdce8be7a4c207e97ab0163d4
  • Description modified (diff)
  • Status changed from new to needs_review

New commits:

38771d3Revert "25218: space fixes"
3aae21dRevert "Trac #25218: fix typo"
0807787Revert "Trac #25218: NumberField attempts to evaluate fractional powers"

comment:5 Changed 21 months ago by slabbe

  • Status changed from needs_review to positive_review

I confirm with the branch I get this:

sage: QQi.<i> = QuadraticField(-1)                                                                   
sage: i^(2/3)                                                                                        
I^(2/3)                                                 
sage: n(_)                                                                                           
0.500000000000000 + 0.866025403784439*I

Bot is green (except for startup time which I think we can ignore because this ticket does not change anything regarding to that).

comment:6 Changed 21 months ago by slabbe

  • Reviewers set to Sébastien Labbé

comment:7 Changed 21 months ago by mkoeppe

  • Milestone changed from sage-9.2 to sage-9.3

comment:8 Changed 20 months ago by vbraun

  • Branch changed from u/mmezzarobba/30783-revert_25218 to 080778741065560bdce8be7a4c207e97ab0163d4
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.