[SciPy-User] complex numbers - sign problem

josef.pktd at gmail.com josef.pktd at gmail.com
Tue May 25 14:17:42 EDT 2010


On Tue, May 25, 2010 at 2:10 PM, Robert Kern <robert.kern at gmail.com> wrote:
> 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)

>>> complex(-1.0, -0.0)
(-1+0j)

Josef
>
> --
> 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
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>



More information about the SciPy-User mailing list