Why does numpy produce a runtime warning (invalid value encountered in log)
when taking the log of a negative number? I noticed that if you coerce the
argument to complex by adding 0j to the negative number, the expected
result is produced (i.e. ln(-1) = pi*i).

I was surprised I couldn't find a discussion on this, as I would have
expected others to have come across this before. Packages like Matlab
handle negative numbers automatically by doing the complex conversion.
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to