Opened 11 years ago
Closed 13 months ago
#11323 closed defect (fixed)
Fix ComplexNumber.__pow__ to allow float^complex
Reported by: | kcrisman | Owned by: | AlexGhitza |
---|---|---|---|
Priority: | major | Milestone: | sage-9.4 |
Component: | basic arithmetic | Keywords: | plot li Li pow |
Cc: | slelievre, tmonteil | 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 changed from sage-5.11 to sage-5.12
comment:2 Changed 8 years ago by
- Milestone changed from sage-6.1 to sage-6.2
comment:3 Changed 8 years ago by
- Milestone changed from sage-6.2 to sage-6.3
comment:4 Changed 8 years ago by
- Milestone changed from sage-6.3 to sage-6.4
comment:5 Changed 4 years ago by
- Summary changed from allow floats to be taken to complex powers to Fix ComplexNumber.__pow__
comment:6 Changed 4 years ago by
- Dependencies set to #24247
comment:7 follow-up: ↓ 8 Changed 14 months ago by
- Branch set to public/11323
- Cc slelievre tmonteil added
- Commit set to f86837fc32a55794a785d14d56cb3dd3aaacadde
- Milestone changed from sage-6.4 to sage-9.3
- Status changed from new to needs_review
- Summary changed from Fix ComplexNumber.__pow__ to Fix ComplexNumber.__pow__ to allow float^complex
comment:8 in reply to: ↑ 7 Changed 14 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 14 months ago by
- Milestone changed from sage-9.3 to sage-9.4
Moving to 9.4, as 9.3 has been released.
comment:10 Changed 13 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 13 months ago by
- Reviewers set to Travis Scrimshaw
- Status changed from needs_review to 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:12 Changed 13 months ago by
Thanks!
comment:13 Changed 13 months ago by
- Branch changed from public/11323 to f86837fc32a55794a785d14d56cb3dd3aaacadde
- Resolution set to fixed
- Status changed from positive_review to 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