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

Travis Oliphant oliphant.travis at
Thu Oct 12 02:41:46 CDT 2006

David Goldsmith wrote:
> I don't use scipy (and don't want to because of the overhead) but it 
> sounds like I should because if I'm taking the square root of a variable 
> whose value at run time happens to be real but less than zero, I *want* 
> the language I'm using to return an imaginary; in other words, it's not 
> the scipy behavior which "scares" me, its the numpy (which I do/have 
> been using) behavior. 

O.K.  Well the functions you want are in numpy.lib.scimath.  I should 
have directed you there.  You actually don't need scipy installed at 
all.  Just import sqrt from numpy.lib.scimath.  I'm sorry I 
misunderstood the issue.


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