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?
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$)