RuntimeWarning: invalid value encountered in arccos
The np.arccos()
function can only take values between -1
and 1
, inclusive.
See: https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.arccos.html
If you simplify to just
np.arccos(90)
(which is the first element in the array being passed to arccos), you'll get the same warning
Why is that? arccos()
attempts to solve x for which cos(x) = 90
. However, such a value doesn't make sense as it's outside of the possible domain for arccos [-1,1]
Also note that at least in recent versions of numpy, this calculation returns nan
>>> import numpy as np
>>> b = np.arccos(90)
__main__:1: RuntimeWarning: invalid value encountered in arccos
>>> b
nan