-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Re-examine complex pow special case handling #89133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Complex power, both via At some point it would be nice to rationalise and document the special-case handling, as far as possible, and to make the behaviour of Note also that there are a *lot* of special cases to consider. We have four real input parameters (the real and imaginary parts of each of the base and the exponent), each of which can be one of the 7 cases nan, -inf, -finite, -0.0, 0.0, finite, inf, for a total of 7**4 = 2401 combinations; moreover, for some cases we might need to distinguish integral from non-integral values, and even integers from odd integers. This is low priority - in many years of mathematical, scientific and numeric work, I've seen little evidence that anyone actually cares about or uses general complex power. Most users are interested in one or more subcases, like:
So a possibly more manageable and more useful subtask would be to ensure that special cases are handled in a sensible manner for these subcases. |
Here's just one example that doesn't make a whole lot of sense: in this case, z ** 1 should be returning z. >>> z = complex(3, float("inf"))
>>> z ** 1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
OverflowError: complex exponentiation |
Aargh. Brain fail. There is no |
The OverflowError should only be raised if finite arguments produce infinite result. Py_ADJUST_ERANGE2 is used improperly. But after fixing this error I get (nan+infj) for z**1, the same as for z*1. |
Is not it a duplicate of bpo-15996? |
Yes, I think it's close enough. Thanks. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: