Author mark.dickinson
Recipients Dennis Sweeney, docs@python, eyadams, mark.dickinson
Date 2021-06-08.16:20:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1623169204.19.0.515385919207.issue44344@roundup.psfhosted.org>
In-reply-to
Content
[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.
History
Date User Action Args
2021-06-08 16:20:04mark.dickinsonsetrecipients: + mark.dickinson, docs@python, Dennis Sweeney, eyadams
2021-06-08 16:20:04mark.dickinsonsetmessageid: <1623169204.19.0.515385919207.issue44344@roundup.psfhosted.org>
2021-06-08 16:20:04mark.dickinsonlinkissue44344 messages
2021-06-08 16:20:04mark.dickinsoncreate