Opened 11 years ago

Closed 6 years ago

#11228 closed defect (fixed)

integer_rational_power problems

Reported by: gerbicz Owned by: AlexGhitza
Priority: major Milestone: sage-7.4
Component: algebra Keywords:
Cc: leif, darij, tscrim Merged in:
Authors: Frédéric Chapoton Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: ff92822 (Commits, GitHub, GitLab) Commit: ff92822014f3efa9fc6518b44f20517179535088
Dependencies: Stopgaps:

Status badges


The following answers are all wrongs/inconsistent with the documentation:

from sage.rings.rational import integer_rational_power
print integer_rational_power(-10, 1/1)
print integer_rational_power(-10, 2/2)
print integer_rational_power(-10, 4/2)
print integer_rational_power(-10, 6/3)
print integer_rational_power(0, 0/1)
print integer_rational_power(0, 1/2)
print integer_rational_power(10, 0/1)

sage gives:

From the first four examples it is clear that sage is unable to observe
if b evaluate as an integer when compute a^b for negative "a" value.
(the answers should be -10,-10,100,100).
The fifth example: as 0^0 is undefined it should return by None.
The sixth example: 0^(1/2)=0 is correct but shows that the documentation 
is broken, because from it: "The positive real root is taken for 
even denominators.", here 2 is even, but the result 0 is not positive.
The seventh example: 10^(0/1)=1 is correct, but from the 
documentation: "b -- a positive Rational", so change the 
documentation or return by None.}}}

Change History (6)

comment:1 Changed 8 years ago by leif

  • Status changed from new to needs_info

SomeoneTM should check what of the above still applies.

comment:2 Changed 6 years ago by chapoton

  • Authors set to Frédéric Chapoton
  • Branch set to u/chapoton/11228
  • Cc leif added
  • Commit set to ff92822014f3efa9fc6518b44f20517179535088
  • Milestone set to sage-7.4
  • Status changed from needs_info to needs_review

New commits:

ff92822trac 11228 fine details in integer_rational_power

comment:3 Changed 6 years ago by chapoton

  • Cc darij tscrim added

a little bit of ticket necromancy..

comment:4 Changed 6 years ago by tscrim

  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review


comment:5 Changed 6 years ago by leif

./sage -Wunused-function?

(If you want to have further fun, perhaps take a look at rational_power_parts() in the same file, the only instance in the Sage library where integer_rational_power() is used at all.)

comment:6 Changed 6 years ago by vbraun

  • Branch changed from u/chapoton/11228 to ff92822014f3efa9fc6518b44f20517179535088
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.