[New-bugs-announce] [issue44970] Re-examine complex pow special case handling

Mark Dickinson report at bugs.python.org
Sat Aug 21 09:26:43 EDT 2021


New submission from Mark Dickinson <dickinsm at gmail.com>:

Complex power, both via `**` and the built-in `pow`, and via `cmath.pow`, is currently a bit of a mess when it comes to special-case handling - particularly handling of signed zeros, infinities, NaNs, and overflow.

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 `**` and `pow` consistent with that of `cmath.pow`. Note that while for all the other cmath functions we have good guidance from the C standards on how special cases should be handled, for pow we're on our own - the C standard refuses to specify anything at all about special case handling.

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:

- positive real base and complex exponent
- complex base and integral exponent
- complex nth root for positive integers n, especially for small n (square root, cube root, ...)

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.

----------
messages: 400025
nosy: mark.dickinson
priority: low
severity: normal
status: open
title: Re-examine complex pow special case handling
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44970>
_______________________________________


More information about the New-bugs-announce mailing list