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?

You have found
$$\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}$$
The first of these is zero only when $-1+x=0$, i.e. $x=1$.
The second is zero only when $-2+y=0$, i.e. $y=2$.
Since $x^2+y^2 - z^2 + 4 = 0$, these two being true simultaneously imply $z=\pm3$.
The distance from $(2,4,0)$ to $(1,2,3)$ and to $(1,2,-3)$ is $\sqrt{14}$ and so this is the shortest distance (if you wish, you can use second derivatives to show it is a minimum).
