<s>[INST] 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?
 [/INST] You can find the minimum using convexity:
$$D^2(H,p) =(2-x)^{2}+(4-y)^{2} + x^{2} + y^{2}+4$$ $$= 2\left(\frac 12 (2-x)^{2} + \frac 12 x^{2}\right) + 2\left(\frac 12(4-y)^{2}+ \frac 12y^{2}\right) + 4$$
$$\stackrel{convexity\: of \: t^2}{\geq}2\left(\frac{2-x+x}2\right)^2 + 2\left(\frac{4-y+y}2\right)^2+ 4 = 14$$
Equality is reached for $2-x=x$ and $4-y=y$ or $x=1$ and $y=2$, hence, $z=\pm 3$.
</s>