Minimum distance between a surface and a point I created this problem which is inspired by some problems I encountered in this site.
What is the minimum distance between point $(1,1,1)$ and a surface defined by $z-xy=10$?
The answer is $\sqrt{18}$ but I am curious how others solve this kind of problem.
 A: We want to minimize 
$$\sqrt{(x-1)^2+(y-1)^2+(xy+10-1)^2}$$
which can be written as
$$\begin{align}&\sqrt{x^2-2x+1+y^2-2y+1+x^2y^2+18xy+81}
\\\\&=\sqrt{(y^2+1)x^2+(18y-2)x+y^2-2y+83}
\\\\&=\sqrt{(y^2+1)\bigg(x^2+\frac{18y-2}{y^2+1}x\bigg)+y^2-2y+83}
\\\\&=\sqrt{(y^2+1)\bigg(\bigg(x+\frac{9y-1}{y^2+1}\bigg)^2-\bigg(\frac{9y-1}{y^2+1}\bigg)^2\bigg)+y^2-2y+83}
\\\\&=\sqrt{(y^2+1)\bigg(x+\frac{9y-1}{y^2+1}\bigg)^2-\frac{(9y-1)^2}{y^2+1}+y^2-2y+83}
\\\\&=\sqrt{(y^2+1)\bigg(x+\frac{9y-1}{y^2+1}\bigg)^2+\frac{(y^2-y-8)^2}{y^2+1}+18}\end{align}$$
So, the minimum distance is $\color{red}{3\sqrt{2}}$ which is attained when
$$x+\frac{9y-1}{y^2+1}=y^2-y-8=0\quad \text{and}\quad z=xy+10$$
i.e.
$$(x,y)=\bigg(\frac{1\pm\sqrt{33}}{2},\frac{1\mp\sqrt{33}}{2},2\bigg)$$
A: mathlove’s answer takes a better approach for this case; but you may not always be so fortunate as to be able to express one variable in terms of the others and to express the objective function in terms of squares that can be set to zero – here’s a general method that doesn’t rely on these features.
We want to minimize $(x-1)^2+(y-1)^2+(z-1)^2$ subject to the constraint $z-xy=10$. Thus we need to find the stationary points of $f(x,y,z)=(x-1)^2+(y-1)^2+(z-1)^2+\lambda(z-xy-10)$, where $\lambda$ is a Lagrange multiplier.
The partial derivatives are
\begin{eqnarray}
\frac{\partial f}{\partial x}&=&2(x-1)-\lambda y\stackrel!=0\;,\\
\frac{\partial f}{\partial y}&=&2(y-1)-\lambda x\stackrel!=0\;,\\
\frac{\partial f}{\partial z}&=&2(z-1)+\lambda\stackrel!=0\;.\\
\end{eqnarray}
These equations correspond to what WE Tutorial School derived in a comment based on geometrical considerations.
If $\lambda\ne-2$, the first two equations are a non-singular system of linear equations for $x,y$ in terms of $\lambda$. Since they are symmetrical with respect to $x$ and $y$, we can set $x=y$ and solve either of them to obtain $x=y=\frac2{2-\lambda}$. The third one allows us to express $z$ in terms of $\lambda$, with $z=1-\frac\lambda2$.
Now we can determine $\lambda$ from the constraint: $1-\frac\lambda2-\left(\frac2{2-\lambda}\right)^2=10$. According to Wolfram|Alpha there is one real solution,
$$
\lambda=\frac13\left(-14-200\sqrt[3]{\frac2{2027-3\sqrt{12081}}}-2^\frac23\sqrt[3]{2027-3\sqrt{12081}}\right)\approx-18.020\;,
$$
which corresponds to $x=y\approx0.0999$ and $z\approx10.010$. The distance at this point is $\sqrt{(x-1)^2+(y-1)^2+(z-1)^2}\approx9.099$.
If $\lambda=-2$, the first two equations are identical and yield $x+y=1$. Here $z=1-\frac\lambda2=2$, and we can determine $x$ and $y$ from the constraint: $2-xy=10$ and thus (with $x+y=1$) we have $2-x(1-x)=10$, with solution $x=\frac{1\pm\sqrt{33}}2$ and accordingly $y=\frac{1\mp\sqrt{33}}2$. Here the distance is $\sqrt{(x-1)^2+(y-1)^2+(z-1)^2)}=3\sqrt2\approx4.243$. Thus this stationary point is closer to $(1,1,1)$, and the minimum distance is $3\sqrt2$.
A: Here is a compilation of ways I think solved the problem.  In solutions 2 and 3, there is an inherent assumption that a minimizing point exists.  However, this is due to the fact that the surface $z-xy=10$ is a closed subset of $\Bbb R^3$.  For an interactive 3d plot, see here.


*

*As in mathlove's solution, we want to minimize $$D(x,y,z)=\sqrt{(x-1)^2+(y-1)^2+(z-1)^2}$$ subject to $z=xy+10$.  That is, we want to minimize $$(x-1)^2+(y-1)^2+\big((xy+10)-1\big)^2=(x-1)^2+(y-1)^2+(xy+9)^2.$$  However $$(x-1)^2+(y-1)^2+(xy+9)^2=(x+y-1)^2+(xy+8)^2+18\ge 18.$$  The equality holds iff $x$ and $y$ are the roots of the polynomial $t^2-t-8$ (and since $z=xy+10$, we must have $z=(-8)+10=2$ at the minimizing point), which gives $$(x,y,z)=\left(\frac{1\pm\sqrt{33}}{2},\frac{1\mp\sqrt{33}}{2},2\right).$$  At this point $D(x,y,z)=\sqrt{18}$.

*This is a vector calculus/geometric solution.  Define $\varphi(x,y,z)=z-xy-10$.  If $Q(u,v,w)$ is a point on the surface given by $\varphi(x,y,z)=0$ that is the closest to $P(1,1,1)$, then $\overrightarrow{PQ}=(u-1,v-1,w-1)$ is parallel to $\nabla\varphi(u,v,w)$.  Since $\nabla\varphi(x,y,z)=(-y,-x,1)$, we get $$(u-1,v-1,w-1)=\lambda(-v,-u,1)$$ for some $\lambda\in \Bbb R$.  Since $Q$ is on the surface $\varphi(x,y,z)=0$, we get $w=uv+10$.  We note that $u\ne v$.  Otherwise, $w=uv+10=u^2+10\ge 10$, so that $|PQ|\geq |w-1|\geq |10-1| =9$, but the point $R(3,-3,1)$ on the surface is only at distance $$\sqrt{(3-1)^2+\big((-3)-1\big)^2+(1-1)^2}=2\sqrt5<9$$ away from $P$.  Now, $$\lambda(u-v)=(-\lambda v)-(-\lambda u)=(u-1)-(v-1)=u-v.$$  As $u\ne v$, we get $\lambda=1$.  Hence, $w-1=\lambda\cdot 1=1$, so $w=2$ and $uv=w-10=-8$.  Furthermore, $$u+v=\big((u-1)-(-\lambda v)\big)+1=0+1=1.$$  Therefore, $u$ and $v$ are the roots of $t^2-t-8$.  That is, $$(u,v,w)=\left(\frac{1\pm\sqrt{33}}{2},\frac{1\mp\sqrt{33}}{2},2\right),$$ so $|PQ|=\sqrt{18}$.

*The square of the distance from an arbitrary point $(x,y,xy+10)$ on the surface $z-xy=10$ to $(1,1,1)$ is $$\delta(x,y)=(x-1)^2+(y-1)^2+\big((xy+10)-1\big)^2=(x-1)^2+(y-1)^2+(xy+9)^2.$$  If $Q(u,v,uv+10)$ is closest to $(1,1,1)$, then $$\frac{\partial \delta}{\partial x}(u,v)=\frac{\partial\delta}{\partial y}(u,v)=0.$$  That is, $$u-1+v(uv+9)=v-1+u(uv+9)=0.$$  Therefore $$(u-v)(uv+8)=\big(v-1+u(uv+9)\big)-\big(u-1+v(uv+9)\big)=0.$$ As in the previous solution, we know that $u\ne v$.  Hence $uv+8=0$ or $uv=-8$.  That is $$u+v-1=u-1+v(uv+9)=0,$$ so $u+v=1$. The rest is as before, and we conclude that the minimizing points are $$(u,v,uv+10)=\left(\frac{1\pm\sqrt{33}}{2},\frac{1\mp\sqrt{33}}{2},2\right).$$  At this point $\sqrt{\delta(u,v)}=\sqrt{18}$.

