Opened 12 years ago
Closed 18 months ago
#11323 closed defect (fixed)
Fix ComplexNumber.__pow__ to allow float^complex
Reported by: | Karl-Dieter Crisman | Owned by: | Alex Ghitza |
---|---|---|---|
Priority: | major | Milestone: | sage-9.4 |
Component: | basic arithmetic | Keywords: | plot li Li pow |
Cc: | Samuel Lelièvre, Thierry Monteil | Merged in: | |
Authors: | Samuel Lelièvre | Reviewers: | Travis Scrimshaw |
Report Upstream: | N/A | Work issues: | |
Branch: | f86837f (Commits, GitHub, GitLab) | Commit: | f86837fc32a55794a785d14d56cb3dd3aaacadde |
Dependencies: | #24247 | Stopgaps: |
Description
In sage.rings.complex_number.ComplexNumber.__pow__??
def __pow__(self, right, modulus): try: return (self.log()*right).exp() except TypeError: pass
makes it so that
float(5)^(0.5+14.1347251*i)
doesn't work.
This means plotting even mpmath.li
for complex values with a lambda function won't work nicely.
Change History (13)
comment:1 Changed 9 years ago by
Milestone: | sage-5.11 → sage-5.12 |
---|
comment:2 Changed 9 years ago by
Milestone: | sage-6.1 → sage-6.2 |
---|
comment:3 Changed 9 years ago by
Milestone: | sage-6.2 → sage-6.3 |
---|
comment:4 Changed 8 years ago by
Milestone: | sage-6.3 → sage-6.4 |
---|
comment:5 Changed 5 years ago by
Summary: | allow floats to be taken to complex powers → Fix ComplexNumber.__pow__ |
---|
comment:6 Changed 5 years ago by
Dependencies: | → #24247 |
---|
comment:7 follow-up: 8 Changed 19 months ago by
Authors: | → Samuel Lelièvre |
---|---|
Branch: | → public/11323 |
Cc: | Samuel Lelièvre Thierry Monteil added |
Commit: | → f86837fc32a55794a785d14d56cb3dd3aaacadde |
Milestone: | sage-6.4 → sage-9.3 |
Status: | new → needs_review |
Summary: | Fix ComplexNumber.__pow__ → Fix ComplexNumber.__pow__ to allow float^complex |
comment:8 Changed 19 months ago by
Please @kcrisman can you provide the plotting example you had in mind?
From a decade ago?
I am not sure. I think I had attempted something like this directly, rather than parametrically.
import mpmath parametric_plot((lambda t: mpmath.ei(log(20)*(0.5+i*RR(t))).real, lambda t: mpmath.ei(log(20)*(0.5+i*RR(t))).imag), (0,14.1), rgbcolor=hue(0.7), plot_points=300) + point((mpmath.ei(log(20)*(0.5+i*14.1)).real, mpmath.ei(log(20)*(0.5+i*14.1)).imag), color='red',size=20)
where I used that on this domain the log integral is the exp integral of the log and somehow that avoided the problem.
But I can't remember what exactly I tried that failed, because presumably I discarded it. Sorry!
comment:9 Changed 19 months ago by
Milestone: | sage-9.3 → sage-9.4 |
---|
Moving to 9.4, as 9.3 has been released.
comment:10 Changed 18 months ago by
Should line 1695 isinstance(right, (int, long, Integer))
be changed to isinstance(right, (int, Integer))
, for python 3, or should it be left as is for backwards compatibility?
comment:11 Changed 18 months ago by
Reviewers: | → Travis Scrimshaw |
---|---|
Status: | needs_review → positive_review |
It's not hurting anything by being there, so I would say leave it since it is not related to this ticket. It might also matter for 16-bit machines since this is Cython code (I'm not 100% sure of this however).
LGTM.
comment:13 Changed 18 months ago by
Branch: | public/11323 → f86837fc32a55794a785d14d56cb3dd3aaacadde |
---|---|
Resolution: | → fixed |
Status: | positive_review → closed |
Please @kcrisman can you provide the plotting example you had in mind?
Please @tmonteil can you test on 32-bit?
New commits:
11323: Fix complex number power so float^complex works