Basis vectors of an arbitrary plane I was trying to find the ortonormal basis vectors $\hat{x}$ and $\hat{y}$ in an arbitrary plane on $\mathbb{R}^3$.
The thing is, my plane is tangent to this surface:
$$f(x, y) = -\frac{k}{\sqrt{x^2 + y^2}}$$

Finding out the plane:
$$\boldsymbol \nabla f(x, y, z) \cdot (x-x_0, y-y_0, z - z_0) = \frac{\partial f}{\partial x} (x-x_0) + \frac{\partial f}{\partial y} (y-y_0)  + \frac{\partial f}{\partial z} (z-z_0) = 0$$
Then I tried to do "reverse engineering" to the way of creating a plane given two vectors that are contained in this plane.
$$\hat{x} \times \hat{y} = \frac{\boldsymbol \nabla f}{||\boldsymbol \nabla f||}$$
I have the value of $\boldsymbol \nabla f$ but, I don't have the values of $\hat{x}$ and $\hat{y}$, but I know some conditions they must obey:
$$\hat{x} \cdot \hat{x} = 1$$
$$\hat{y} \cdot \hat{y} = 1$$
$$\hat{x} \cdot \hat{y} = 0$$
And also, this ortonormal bases, must depend on the position of a point:
$$\vec{r} = (x_0, y_0, z_0)$$
So I should rewrite $\hat{x}$ as $\hat{x}(\vec{r})$ and $\hat{y}$ as $\hat{y}(\vec{r})$.
But, bad luck for me, when I expand the expressions, there are a total of 6 systems of equations I have to solve. My question is: Is there any method to compute this vectors faster or in a more efficient way?

I think the key issue in your calculation is that $\nabla f$ is not a vector in $\mathbb{R}^3$ orthogonal to the tangent plane (what does $\frac{\partial f}{\partial z}$ even mean, in your expression?). It is a 2D vector in the $xy$-plane that points in the direction where the tangent plane most steeply ascends.
There are two vectors that are obviously tangent to the plane:
$$\left(1,0,\frac{\partial f}{\partial x}\right)$$
$$\left(0,1,\frac{\partial f}{\partial y}\right)$$
and in general, for any vector $(v_x, v_y)$ in the $xy$-plane,
$$(v_x, v_y, \nabla f \cdot (v_x,v_y))$$
will lie in your tangent plane (the above two are special cases).
To find an orthonormal basis, compute two tangent vectors, and then orthogonalize them using Gram-Schmidt.
