Should numpy.sqrt(-1) return 1j rather than nan?

Greg Willden gregwillden at
Wed Oct 11 22:17:13 CDT 2006

On 10/11/06, Travis Oliphant <oliphant at> wrote:
> Stefan van der Walt wrote:
> >Further, if I understand correctly, changing sqrt and power to give
> >the right answer by default will slow things down somewhat.  But is it
> >worth sacrificing intuitive usage for speed?
> >
> For NumPy, yes.
> This is one reason that NumPy by itself is not a MATLAB replacement.

This is not about being a Matlab replacement.
This is about correctness.
Numpy purports to handle complex numbers.
Mathematically, sqrt(-1) is a complex number.
Therefore Numpy *must* return a complex number.
Speed should not take precedence over correctness.

If Numpy doesn't return a complex number then it shouldn't pretend to
support complex numbers.


Linux.  Because rebooting is for adding hardware.
-------------- next part --------------
An HTML attachment was scrubbed...
-------------- next part --------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
-------------- next part --------------
Numpy-discussion mailing list
Numpy-discussion at

More information about the Numpy-discussion mailing list