Message236836
> 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) |
|
Date |
User |
Action |
Args |
2015-02-27 20:48:13 | mark.dickinson | set | recipients:
+ mark.dickinson, rhettinger, benjamin.peterson, stutzbach, ezio.melotti, 夏熙临 |
2015-02-27 20:48:13 | mark.dickinson | set | messageid: <1425070093.14.0.765931645822.issue23523@psf.upfronthosting.co.za> |
2015-02-27 20:48:13 | mark.dickinson | link | issue23523 messages |
2015-02-27 20:48:12 | mark.dickinson | create | |
|