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

Stefan van der Walt stefan at
Wed Oct 11 19:41:08 CDT 2006

On Wed, Oct 11, 2006 at 08:24:01PM -0400, A. M. Archibald wrote:
> What is the desired behaviour of sqrt?


> Should it return a complex array only when any entry in its input is
> negative? This will be even *more* surprising when a negative (perhaps
> even -0) value appears in their matrix (for example, does a+min(a)
> yield -0s in the minimal values?) and suddenly it's complex.

Luckily sqrt(-0.) gives -0.0 and not nan ;)


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

More information about the Numpy-discussion mailing list