Mark Dickinson <dicki...@gmail.com> added the comment:

[Dennis]

> I think the relevant property is that the exponent is not an integer

Yep: the delegation to complex pow kicks in after handling infinities and nans, 
and only for strictly negative base (-0.0 doesn't count as negative for this 
purpose) and non-integral exponent.

Here's the relevant code: 
https://github.com/python/cpython/blob/257e400a19b34c7da6e2aa500d80b54e4c4dbf6f/Objects/floatobject.c#L773-L782

To avoid confusion, we should probably not mention fractions like `1/3` and 
`4/3` as example exponents in the documentation, since those hit the 
What-You-See-Is-Not-What-You-Get nature of binary floating-point. 
Mathematically, `z^(1/3)` is a very different thing from 
`z^(6004799503160661/18014398509481984)` for a negative real number `z`, and 
the latter is what's _actually_ being computed with `z**(1/3)`. The advantage 
of the principal branch approach is that it's continuous in the exponent, so 
that `z^(1/3)` and `z^(6004799503160661/18014398509481984)` only differ by a 
tiny amount.

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44344>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to