Should numpy.sqrt(-1) return 1j rather than nan?
Alan G Isaac
aisaac at american.edu
Thu Oct 12 09:53:12 CDT 2006
On Thu, 12 Oct 2006, Stefan van der Walt apparently wrote:
> I tried to explain the argument at
> http://www.scipy.org/NegativeSquareRoot
Helpful. But you start off by saying:
In mathematics, the above assumption is true -- that
the square root of -1 is 1j.
Since square root is (here) a function, and part of the
function definition is the domain and codomain, this
statement is not correct. If the codomain is real numbers,
the domain must correspondingly be (a subset of) the
nonnegative reals. The nan output is the result of an
**invalid** input.
So the question is really: "Why is a negative real number an
invalid input in this implementation", or "Why in this
implementation is the type of the output restricted by the
type of the input?" You get a good start on answering that.
Cheers,
Alan Isaac
-------------------------------------------------------------------------
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
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
More information about the Numpy-discussion
mailing list