Opened 6 years ago

Closed 6 years ago

#21517 closed defect (fixed)

Log of integer to base 1/n can have exact numeric results

Reported by: Ralf Stephan Owned by:
Priority: major Milestone: sage-7.4
Component: numerical Keywords:
Cc: Merged in:
Authors: Ralf Stephan Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: 4aba8a9 (Commits, GitHub, GitLab) Commit: 4aba8a99c827b6ca3088c5703a98bb0b0c1271e9
Dependencies: Stopgaps:

Status badges

Description

Log of integer to base 1/n can have nonsymbolic results but this is not recognized in Integer::log():

sage: ZZ(8).log(1/2)
log(8)/log(1/2)

nor in Integer.exact_log():

sage: ZZ(8).exact_log(1/2)
...
TypeError: no conversion of this rational to integer

Change History (8)

comment:1 Changed 6 years ago by Ralf Stephan

Branch: u/rws/log_of_integer_to_base_1_n_can_have_exact_numeric_results

comment:2 Changed 6 years ago by Ralf Stephan

Authors: Ralf Stephan
Commit: 0ae5fd8ffaff03cf83217a68b2247b1556a934c2
Status: newneeds_review

comment:3 Changed 6 years ago by git

Commit: 0ae5fd8ffaff03cf83217a68b2247b1556a934c2de1acfad2c24ba8c587eeb84cdba0d88579c614a

Branch pushed to git repo; I updated commit sha1. New commits:

de1acfa21517: handle ZZ.log(1/n)

comment:4 Changed 6 years ago by Travis Scrimshaw

I would avoid doing the exact_log twice:

        if type(m) == Integer and type(self) == Integer:
             elog = self.exact_log(m):
             if m**elog == self:
                 return elog

Similarly for the other one. Otherwise LGTM.

comment:5 Changed 6 years ago by Travis Scrimshaw

Reviewers: Travis Scrimshaw

comment:6 Changed 6 years ago by git

Commit: de1acfad2c24ba8c587eeb84cdba0d88579c614a4aba8a99c827b6ca3088c5703a98bb0b0c1271e9

Branch pushed to git repo; I updated commit sha1. New commits:

4aba8a921517: avoid duplicate computations

comment:7 Changed 6 years ago by Ralf Stephan

Status: needs_reviewpositive_review

Thanks.

comment:8 Changed 6 years ago by Volker Braun

Branch: u/rws/log_of_integer_to_base_1_n_can_have_exact_numeric_results4aba8a99c827b6ca3088c5703a98bb0b0c1271e9
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.