-
-
Notifications
You must be signed in to change notification settings - Fork 654
Closed
Labels
Description
Steps To Reproduce
sage: log(8,-2)
3*log(2)/(I*pi + log(2))
sage: 8.log(-2)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[2], line 1
----> 1 Integer(8).log(-Integer(2))
File ~/SAGE_ROOT/src/sage/rings/integer.pyx:2861, in sage.rings.integer.Integer.log()
2859 cdef int self_sgn
2860 if m is not None and m <= 0:
-> 2861 raise ValueError("log base must be positive")
2862 self_sgn = mpz_sgn(self.value)
2863 if self_sgn < 0 and prec is None:
ValueError: log base must be positive
sage: (8.0).log(-2.0)
0.139260970636224 - 0.631180872623791*I
------------------------------------------------------------------------------------[Another Example]--------------------------------------------------------------------------------------------
sage: log(8,0)
0
sage: 8.log(0)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[10], line 1
----> 1 Integer(8).log(Integer(0))
File ~/SAGE_ROOT/src/sage/rings/integer.pyx:2861, in sage.rings.integer.Integer.log()
2859 cdef int self_sgn
2860 if m is not None and m <= 0:
-> 2861 raise ValueError("log base must be positive")
2862 self_sgn = mpz_sgn(self.value)
2863 if self_sgn < 0 and prec is None:
ValueError: log base must be positive
sage: (8.0).log(0.0)
-0.000000000000000
Expected Behavior
The log method should give consistent output and not ValueError
which creates confusion
Actual Behavior
Gives an absurd ValueError
in some cases while provides an answer for some other
Additional Information
No response
Environment
- OS: EndeavourOS x86_64 (based on Linux 6.14.2-arch1-1) but may happen in any
- Sage Version: any 10+
Checklist
- I have searched the existing issues for a bug report that matches the one I want to file, without success.
- I have read the documentation and troubleshoot guide