I have a numpy array, x, that is calculated from a complicated equation:
x = (QT-m_μ_Q*M_T)/(m*σ_Q*Σ_T)
print(x)
print(x[0], x[1], x[2])
print(1.0-x)
This prints:
[ 1.  1.  1.]
1.0 1.0 1.0
[ -2.22044605e-16   3.33066907e-16  -4.44089210e-16]
Notice that the last line prints out something small and very close to zero but is non-zero. My next step is to take the square root of each value, so it should not contain negative values.
Explicitly starting with an array containing ones:
y = np.array([1., 1., 1.])
print(y)
print(y[0], y[1], y[2])
print(1.0-y)
produces the correct result so I'm not sure what the difference is:
[ 1.  1.  1.]
1.0 1.0 1.0
[ 0.  0.  0.]
 
     
    