[issue4139] Major error in cmath routines

Mark Dickinson report at bugs.python.org
Fri Oct 17 19:00:21 CEST 2008


Mark Dickinson <dickinsm at gmail.com> added the comment:

This is not a bug, at least in the sense that the behaviour of Python 
2.6 is intentional:  asin has branch cuts from 1 to infinity and -1 to -
infinity along the real axis.  As explained by the note at the top of 
the cmath documentation, on platforms with signed zeros (which is pretty 
much all platforms these days), the sign of the imaginary part of the 
argument is used to determine which side of the branch cut to use.  So:

>>> import cmath
>>> cmath.asin(complex(2.0, 0.0))
(1.5707963267948966+1.3169578969248166j)
>>> cmath.asin(complex(2.0, -0.0))
(1.5707963267948966-1.3169578969248166j)

This is fairly standard practice, and usually the right thing in 
applications;  see the Kahan paper referred to at the bottom of the 
cmath docs.  It also follows the suggestions outlined in Annex G of the 
C99 standard.

----------
resolution:  -> invalid
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4139>
_______________________________________


More information about the Python-bugs-list mailing list