<s>[INST] Minimizing distance from a point to a parabola Problem: The point on the curve $x^2 + 2y = 0$ that is nearest the point $\left(0, -\frac{1}{2}\right)$ occurs at what value of y?
Using the distance formula, I get my primary equation: $L^2 = (x-0)^2 + \left(y-\left(-\frac{1}{2}\right)\right)^2$
However, when using the secondary equation $x^2 + 2y = 0$ to write $L^2$ as a function of a single variable and then minimizing $L^2$, thus minimizing $L$, I am getting conflicting answers. 
Let $D = L^2 = (x-0)^2 + \left(y-\left(-\frac{1}{2}\right)\right)^2$
Approach 1: substituting $y = -\frac{x^2}{2}$ into our primary equation,
$$D = (x-0)^2 + \left(-\frac{x^2}{2}-\left(-\frac{1}{2}\right)\right)^2$$
$$\frac{dD}{dx} = 2x + 2\left(\frac{x^2}{2}-\frac{1}{2}\right)(x)$$
$$\frac{dD}{dx} = x(x^2+1)$$
Therefore, $D$ has a critical point at x = 0. Using the first derivative test, $\frac{dD}{dx} < 0$ for all $x<0$ and $\frac{dD}{dx}>0$ for all $x>0$, therefore a minimum exists at $x = 0$. At $x=0$, $y = 0$.
Approach 2: substituting $x^2 = -2y$ into our primary equation,
$$D = -2y + \left(y-\left(-\frac{1}{2}\right)\right)^2$$
$$\frac{dD}{dy} = -2 + 2\left(y+\frac{1}{2}\right)$$
$$\frac{dD}{dy} = 2y-1$$
Therefore, $D$ has a critical point at $y = \frac{1}{2}$. Using the first derivative test, $\frac{dD}{dy} < 0$ for all $y<\frac{1}{2}$ and $\frac{dD}{dy}>0$ for all $y>\frac{1}{2}$, therefore a minimum exists at $y = \frac{1}{2}$.

Why do the results differ? What faulty assumption(s) have I made? Thanks in advance.
 [/INST] The correct solution is $(0,0)$. Your first approach is correct.
For the second approach, note that the domain of $D(y)$ is $y \le 0$, so the solution $y= \frac12$ cannot be correct. 
Also note that $D$ is always decreasing for $\forall y \le 0$, therefore $D(y)$ attains its minimum at $y=0$
</s>