How can I take the square root of -1 using python?

前端 未结 5 506
天涯浪人
天涯浪人 2020-12-06 17:59

When I take the square root of -1 it gives me an error:

invalid value encountered in sqrt

How do I fix that?

///         


        
5条回答
  •  星月不相逢
    2020-12-06 18:05

    The square root of -1 is not a real number, but rather an imaginary number. IEEE 754 does not have a way of representing imaginary numbers.

    numpy has support for complex numbers. I suggest you use that: http://docs.scipy.org/doc/numpy/user/basics.types.html

提交回复
热议问题