Below I am pasting equations of superquadrics:

for $\varepsilon_1 = 0.5$ and $\varepsilon_2 = 0.5$ some values are not valid (e.g. $\cos(\pi)^{0.5}$).
I would appreciate if anyone explained how to correctly calculate $x, y$, and $z$ values for arbitrary $\eta, \omega$, and $\varepsilon$.
I tried to use the following function to calculate the distance between the body surface and point $(x_0, y_0, z_0)$ but in case of $\varepsilon = 0.5$, I get an error:
def get_distance(x, x0, y0, z0, alpha1, alpha2, alpha3, epsilon1, epsilon2):
return np.sqrt((x0 - alpha1*np.cos(x[0])**epsilon1*np.cos(x[1])**epsilon2)**2 + (y0 - alpha2*np.cos(x[1])**epsilon1*np.sin(x[1])**epsilon2
You should take the absolute values of the trig functions, $\cos \eta, \sin \eta, \cos \omega, \sin \omega$ before raising them to powers, then carry the signs over. Non-integer powers of negative numbers are not well defined.