[SciPy-User] complex numbers - sign problem

Robert Kern robert.kern at gmail.com
Tue May 25 14:10:58 EDT 2010


On Sat, May 22, 2010 at 08:06,  <et.barthel at free.fr> wrote:
> Hi,
> not sure it's the right place to ask the question, but I don't really know where
> to send it.
> I have an issue with cmath sign handling:
> In [75]: -1-0.j
> Out[75]: (-1+0j)
>
> In [76]: -(1+0.j)
> Out[76]: (-1-0j)
> is a bit strange by itself - at least to me - but combined with a multivalued
> function which has a branch cut on the x-axis leads to significant and
> potentially harmful sign problem. Of course one can fiddle around the problem
> but I would like to be sure if this is a bug or if there is some sense to it.

This looks like cornercase with Python's parsing of the imaginary
literal. You can work around it by explicitly using the complex()
constructor:

In [7]: -1.0 - 0.0j
Out[7]: (-1+0j)

In [8]: complex(-1.0, -0.0)
Out[8]: (-1-0j)

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the SciPy-User mailing list