What is the closest point to $(0,-1/2)$ on the curve $x^2+2y=0$? Why can't I differentiate over $y$? Let $L$ be the distance between $(x,y)$ on the curve $x^2+2y=0$ and $(0,-1/2)$.
Then $L^2=x^2+(y+\frac{1}{2})^2=-2y+(y+\frac{1}{2})^2$,
$\frac{dL^2}{dy}=-2+2(y+\frac{1}{2})=0$,
which gives $y=1/2$.
But this is clearly incorrect. $y=1/2$ does not even lie on the curve!
I know that if we express $y$ in terms of $x$, and then differentiate over $x$, we can get the correct answer $(0,0)$.
But I don't figure out what's wrong when we differentiate over $y$.
 A: Interesting puzzle.
If you draw a picture you'll see the problem. Both the picture and the algebra tell you that $y$ must be nonpositive.
Now think more carefully about how you find the minimum of a differentiable function. That can occur at a root of the derivative or at an end point of the domain. 
In this case the minumum is at $0$; the distance increases as $|y|$ increases along the negative $y$-axis.
A: What you have is a minimization problem of the quadratic function $x^2+(y+\frac12)^2$ under the quadratic constraint $x^2+2y=0$.
As $y$ is constrained (it must be non-positive), nothing guarantees that the minimum occurs at a stationary point, it can occur at the endpoint $y=0$ instead.
On the opposite, $x$ is unconstrained.
A: You have Ethan Bolker's answer.  I'm going to ask you a question that might make it clearer.  Let $f$ have domain $(-1,3]$ and be given by $f(x) = x^2$ on that domain.  Where is the maximum of $f$?  (It's not where the derivative is zero; that's the global minimum.)  Could we have gotten a bigger maximum if (somehow) we could expand the domain a little?  Does this mean, in addition to points where the derivative is zero, we must check points where the derivative is undefined (for instance, where we cannot take limits from both sides)?
A: Minimize $L^2=x^2+\left(y+\frac12\right)^2$ subject to $x^2+2y=0$.
The constrained optimization problem can be solved by the method of substitution. Substituting $y=-\frac{x^2}{2}$ works smoothly as OP stated.
Substituting $x^2=-2y$ has additional implicit constraints on $x$ and $y$:
$$y=-\frac{x^2}{2} \Rightarrow x\in (-\infty,+\infty); y\in (-\infty,0].$$
So after substitution $x^2=-2y$, we get another constrained optimization problem:
$$\text{Min} L^2=-2y+\left(y+\frac12\right)^2 \ \text{s.t.} \ \ y\in (-\infty,0].$$
According to Extreme value theorem, the optimum occurs either at critical (provided it belongs to feasible region) or border points. The critical point $y=\frac12$ does not belong to $(-\infty,0]$. Hence the minimum is at the border $y=0$. Note that $L^2(-\infty)=+\infty$.
A: Correct me if wrong:
Pedestrian approach:
1) $y=-(1/2)x^2$ is a parabola, $Y-$axis is symmetry axis, vertex $(0,0)$, opening downward.
2) Point $P (0,-1/2)$.
Restrict calculation to 3rd quadrant, symmetry, i.e.
$x\ge 0$, $y \le 0$.
3) We are looking for a point $(x,y)$ on the parabola that has minimal distance to $P$.
4)$D(y)=  -2y +(y+1/2)^2$, where $D(y)= (distance)^2$.
Recall $y \le 0$:
$D'(y) = -2 +2(y+1/2) =$
$ -1 +2y \lt 0$.
Hence $D'(y)$ is a strictly decreasing function.
The maximum is at $y=0$.
$D(y=0)= 1/4$.
Formally:  $D'(y) =0$ , gives $y = 1/2$, 
but this value is ruled out since we consider the 3rd quadrant , where $x\ge0, y\le 0$.
Note: The function $D(y)$ , $y \in R$,  has a minimum at $y=1/2$, which is $D(y=1/2)=0$.
