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: You are after the minimum of $(x-2)^2+(y-4)^2+z^2$ (no, I did not use the square root) under the restriction that $x^2+y^2-z^2=-4$. It is natural to use here the method of Lagrange multipliers. So, one has to solve the system$$\left\{\begin{array}{l}2(x-2)=2\lambda x\\2(y-4)=2\lambda y\\2z=-2\lambda z\\x^2+y^2-z^2=-4.\end{array}\right.$$Its only solutions are $(x,y,z,\lambda)=(1,2,\pm3,-1)$. So, the distance from $H$ to $(2,4,0)$ is$$\sqrt{(1-2)^2+(2-4)^2+(\pm3)^2}=\sqrt{14}.$$
A: 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$.
A: 
Let $H = \{(x,y,z)\ \in \mathbb{R}^{3}: x^2+y^2 - z^2 + 4 = 0\}$.
Compute the shortest distance between $H$ and the point $P\equiv(2,4,0)$.

Approach other than Lagrange's multipliers:
Since the graph is symmetric in $\phi$, you can also minimize $(\sqrt{2^2+4^2}-r)^2+(r^2+4)=2r^2-2\sqrt{20}r+24$ for some $r$, where $\sqrt{(\sqrt{2^2+4^2}-r)^2+(r^2+4)}$ is the distance between the point $(\sqrt{2^2+4^2},\phi,0)$ and $(r,\phi,z)$.

A: 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\}$.
A: 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).
