Distance between set and point, confused of partial derivatives. Let $H = \{(x,y,z)\ \in \mathbb{R}^{3}: x^2+y^2 - z^2 + 4 = 0$
Compute the shortest distance between H and point $p=(2,4,0)$.
I am a bit confused because I tried a direct approach.
$$ x^2+y^2 + 4 =  z^2$$
Let $D(H,p) = \sqrt{(2-x)^{2}+(4-y)^{2} + x^{2} + y^{2}+4}$
So I tried compute $$\frac{\partial D}{\partial x} = (\sqrt{2} (-1 + x))/\sqrt{12 - 2 x + x^2 - 4 y + y^2}$$
$$\frac{\partial D}{\partial y} = (\sqrt{2} (-2 + y))/\sqrt{12 - 2 x + x^2 - 4 y + y^2}$$
It seems not nice to compare with zero.
Do you have another idea?

A fraction is zero when its numerator is zero and its denominator is not.  If your fraction is $0/0$, apply l'Hopital's rule until you can resolve its value.
You wish to study
$$  \frac{\partial D}{\partial x} = (\sqrt{2} (-1 + x))/\sqrt{12 - 2 x + x^2 - 4 y + y^2}  \text{.}  $$
This fraction is zero if $\sqrt{2}(-1+x) = 0$, so when $x = 1$, as long as $\left. \sqrt{12 - 2 x + x^2 - 4 y + y^2} \right|_{x=1}$ is not zero.  Since
$$  \left. \sqrt{12 - 2 x + x^2 - 4 y + y^2} \right|_{x=1} = \sqrt{11-4y+y^2}  $$
Since the discriminant of that quadratic in $y$ is $-28 < 0$, the denominator is not simultaneously zero for any real value of $y$.  (The roots of the quadratic in $y$ are $y = 2 \pm \mathrm{i}\,\sqrt{7}$, neither of which is a real number.)  Therefore, $\partial D / \partial x = 0$ for $x = 1$ and all $y$, i.e., the set $\{1\} \times \Bbb{R}$ in $\Bbb{R}^2$.
Applying the same analysis to $\partial D / \partial y$, the numerator is zero when $y = 2$ and the denominator for that specialization of $y$ is $\sqrt{8-2x+x^2}$.  Again, the discriminant of this quadratic is negative, so it has no real roots and $\partial D/\partial y$ is zero at every point of $\Bbb{R} \times \{2\}$.
