I have this code and unfortunately it doesn't work for me. I get this error:
RuntimeWarning: invalid value encountered in sqrt z1 = np.sqrt(r1 ** 2 - x ** 2 - y ** 2)
RuntimeWarning: invalid value encountered in sqrt z2 = np.sqrt(r1 ** 2 - x ** 2 - y ** 2) * (-1)
The location of the point is: [nan nan nan]
Edit, I have solution of this problem:
z1 = np.sqrt(r1 ** 2 - x ** 2 - y ** 2)
z2 = np.sqrt(r1 ** 2 - x ** 2 - y ** 2) * (-1)
It is not working beacouse we can't calculate NaN * (-1) and thats why the rest of the code is not working.
Instead, we should write the code like this:
import cmath
z1 = cmath.sqrt(pow(r1, 2.) - pow(x, 2.) - pow(y, 2.))
zx = z1.real
zy = z1.imag
val = zx + zy
z2 = val * (-1)
and now its working correct.