Determine the point on the plane $4x-2y+z=1$ that is closest to the point $(-2, -1, 5)$ Determine the point on the plane $4x-2y+z=1$ that is closest to the point $(-2, -1, 5)$. This question is from Pauls's Online Math Notes. He starts by defining a distance function: 
$z = 1 - 4x + 2y$
$d(x, y) = \sqrt{(x + 2)^2 + (y + 1)^2 + (-4 -4x + 2y)^2}$
However, at this point, to make the calculus simpler he finds the partial derivatives of $d^2$ instead of $d$. Why does this give you the same answer? 
 A: In general, if $$d(x,y)=\sqrt {f(x,y)}$$ for some positive function $f(x,y)$ then the minima of d will correspond to the minima of f.  So, if $f(x,y)$ is differentiable, it makes sense to search for solutions of $$ \frac{\partial f}{\partial x}=0, \frac{\partial f}{\partial y}=0$$ where $f=d^2$ rather than calculating partial derivatives of $d$.
In any case, $$ \frac{\partial d}{\partial x} = 0$$ is the same as $$\frac {1}{2} \frac {1}{\sqrt {f(x,y)}} \frac{\partial f}{\partial x}=0 $$ by applying the chain rule which requires $$\frac{\partial f}{\partial x}=0$$ which is where we started. (Similar conclusion for derivative with respect to $y$)
A: Here is  a simple solution using tools from middle school for the computation:
Denote $x,y,z$ the coordinates of the orthogonal projection of the point $(-2,-1,5)$
 It satisfies the equations of  proportionality:
$$\frac{x+2}4=\frac{y+1}{-2}=\frac{z-5}1$$
This common ratio is also equal to 
$$\frac{4(x+2)-2(y+1)+1(z-5)}{4^2+(-2)^2+1^2}=\frac{(4x-2y+z)+1}{21}=\frac{2}{21}$$
whence the solution
\begin{cases}
x=-2+\dfrac 8{21}=-\dfrac{34}{21},\\[1ex]
y=-1-\dfrac 4{21}=-\dfrac{25}{21}, \\[1ex]
z= 5+\dfrac 2{21}=\dfrac{105}{21}.
\end{cases}
With these elements, the distance squared is
$$d^2=(x+2)^2+(y+1)^2+(z-5)^2=\frac{8^2+(-4)^2+2^2}{21^2}=\frac{84}{21^2}=\frac{4}{21}$$
and finally $\;d=\dfrac 2{\sqrt{21}}.$
As to your exact question, the differential of $d^2$ is $2d D(d)$, hence the critical values are obtained at the same points, and as $d>0$, $d^2$ and $d$ both increase or both decrease.
