This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mark.dickinson
Recipients benjamin.peterson, ezio.melotti, mark.dickinson, rhettinger, stutzbach, 夏熙临
Date 2015-02-27.20:48:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1425070093.14.0.765931645822.issue23523@psf.upfronthosting.co.za>
In-reply-to
Content
> Both are correct
Well, strictly speaking only the output with positive imaginary part is correct here: the recommendations of C99 Annex G (which Python's cmath module follows) use the sign of the zero imaginary part to determine which 'side' of the branch cut the input lies on.  In this case, -1.89 is interpreted as complex(-1.89, 0.0), so the imaginary part is a positive zero, and the sign of the imaginary part of the result matches that for complex(-1.89, small_and_positive).

So all four of the following are correct:

>>> cmath.atanh(complex(-1.89, 0.0))
(-0.5888951591901462+1.5707963267948966j)
>>> cmath.atanh(complex(-1.89, -0.0))
(-0.5888951591901462-1.5707963267948966j)
>>> cmath.atanh(complex(1.89, 0.0))
(0.5888951591901462+1.5707963267948966j)
>>> cmath.atanh(complex(1.89, -0.0))
(0.5888951591901462-1.5707963267948966j)
History
Date User Action Args
2015-02-27 20:48:13mark.dickinsonsetrecipients: + mark.dickinson, rhettinger, benjamin.peterson, stutzbach, ezio.melotti, 夏熙临
2015-02-27 20:48:13mark.dickinsonsetmessageid: <1425070093.14.0.765931645822.issue23523@psf.upfronthosting.co.za>
2015-02-27 20:48:13mark.dickinsonlinkissue23523 messages
2015-02-27 20:48:12mark.dickinsoncreate