Perhaps this is an algorithmic issue, but the following piece of code
numpy.power((-1+0j),0.5)
produces the following output
(6.1230317691118863e-17+1j)
Analogous expressions e.g. numpy.power(complex(-1),.5) yield the same result, however – numpy.sqrt(complex(-1)) yields the expected result of 1j. Clearly the result should have no real part, so I am missing something crucial or do I need to report this to numpy dev’s.
In case anyone asks, no I can not round away the real part (I need full precision for this calculation) and yes I need to use the power function.
It’s a side effect of the implementation of
numpy.power()for complex numbers. The stdlib exhibits the same issue.