[Numpy-discussion] sqrt and divide

Stefan van der Walt stefan at sun.ac.za
Tue Apr 11 22:47:14 EDT 2006


Hi all

Two quick questions regarding unintuitive numpy behaviour:

Why is the square root of -1 not equal to the square root of -1+0j?

In [5]: N.sqrt(-1.)
Out[5]: nan

In [6]: N.sqrt(-1.+0j)
Out[6]: 1j

Is there an easier way of dividing two scalars than using divide?

In [9]: N.divide(1.,0)
Out[9]: inf

(also 

In [8]: N.divide(1,0)
Out[8]: 0

should probably ruturn inf / nan?)

Regards
Stéfan






More information about the NumPy-Discussion mailing list