Find the point of the parabola $\displaystyle{ x =y^2 }$ nearest to the point $(3,-3)\;$ . This is illustrated by the illustrated diagram below. Note that this example is algebraically somewhat more involved than the preceding two.
Experimentation suggests that the distance is minimized when $y$ is about $-1.83\,$ , and this minimal distance is approximately $1.22\;$ . There is also an unusual dip in the distance function when $y$ is approximately $1\;$ . As $y$ increases from $0\,$ , when the distance increases to about $4.473\,$ , hovers there for a bit, then dips slightly when $y$ is about $1\,$ , and then increases rapidly as $y$ continues to get larger.
Letting the second name ( $\,y\,$ ) of a point on the curve serve as our variable, we wish to minimize
$\displaystyle{ \text{dist}=\sqrt{(x-3)^2+(y-(-3))^2}=\sqrt{\left(y^2-3\right)^2+(y-(-3))^2}\; {\rm .} }$
In fact, as this function is strictly positive, and squaring is an increasing function for positive real numbers, the minimum of this occurs for precisely the same $y$ value as the minimum of its square. Thus we instead minimize
$\displaystyle{ \text{dist}^2=(x-3)^2+(y-(-3))^2=\left(y^2-3\right)^2+(y-(-3))^2 \; {\rm .} }$
This is a common simplification of a problem – optimize a related but easier function.
This new function, $\displaystyle{ \, \text{dist}^2(y)\, }$ , is defined for all $y$ values. We cannot directly apply the Extreme Value Theorem. Nevertheless, let us consider the derivative of this function.
$\displaystyle{ \frac{\mathrm{d}\phantom{y}}{\mathrm{d}y}\,\left(\text{dist}^2(y)\right) =2\, \left(2\, y\, \left(y^2-3\right) +(y+3)\right) \; {\rm .} }$
This exists for all $y\in \mathbb{R}\; $ . So if we have a minimum, it will be at a place where the derivative $=0\;$ . We proceed to solve this equation.
As $\displaystyle{ \frac{\mathrm{d}\phantom{y}}{\mathrm{d}y}\,\left(\text{dist}^2(y)\right) =2\, \left(2\, y\, \left(y^2-3\right) +(y+3)\right) =0 }$ when $\displaystyle{ 2\, y\, \left(y^2-3\right) +(y+3) =0\, }$ , or $\displaystyle{ 2\, y^3 -5\, y +3 =0\, }$ , we study this cubic equation. It factors to $\displaystyle{ (y-1)\,\left( 2\, y^2 +2\, y -3 \right) =0\, }$ , and thus $\displaystyle{ \frac{\mathrm{d}\phantom{y}}{\mathrm{d}y}\,\left(\text{dist}^2(y)\right) =0 }$ when either $y=1\,$ , or $\displaystyle{ 2\, y^2 +2\, y -3 =0\; }$ . This last quadratic equation has the two solutions $\displaystyle{ y =-\frac{1}{2} +\frac{1}{2}\,\sqrt{7} \sim .8229 }$ and $\displaystyle{ y =-\frac{1}{2} -\frac{1}{2}\,\sqrt{7} \sim -1.8229\; }$ .
Consider the derivative $\displaystyle{ \frac{\mathrm{d}\phantom{y}}{\mathrm{d}y}\,\left(\text{dist}^2(y)\right) =2\, \left(2\, y\, \left(y^2-3\right) +(y+3)\right) = 4\, y^3 -10\, y +6\, }$ , for $y\in \mathbb{R}\;$ . We have seen that it $=0$ for $y=1\,$ , $\displaystyle{ \, y =-\frac{1}{2} +\frac{1}{2}\,\sqrt{7}\, }$ , and $\displaystyle{ y =-\frac{1}{2} -\frac{1}{2}\,\sqrt{7}\; }$ . On the remaining intervals of $\mathbb{R}\,$ , that is on $\displaystyle{ \left( -\infty, -\frac{1}{2} -\frac{1}{2}\,\sqrt{7} \right)\, }$ , $\displaystyle{ \, \left( -\frac{1}{2} -\frac{1}{2}\,\sqrt{7} , -\frac{1}{2} +\frac{1}{2}\,\sqrt{7} \right)\, }$ , $\displaystyle{ \, \left( -\frac{1}{2} +\frac{1}{2}\,\sqrt{7} , 1 \right)\, }$ , and $(1,\infty)\,$ , this derivative is negative, positive, negative and positive respectively. We see that $\displaystyle{ y =-\frac{1}{2} -\frac{1}{2}\,\sqrt{7} }$ and $y=1$ are local minima, and $\displaystyle{ y =-\frac{1}{2} +\frac{1}{2}\,\sqrt{7} }$ is a local maximum, of the function $\displaystyle{ \text{dist}^2=\left(y^2-3\right)^2+(y+3)^2 \; }$ . The function has a minimum and it must occur at one of $\displaystyle{ y =-\frac{1}{2} -\frac{1}{2}\,\sqrt{7} }$ and $y=1\;$ .
Since $\displaystyle{ \text{dist}^2\left( y =-\frac{1}{2} -\frac{1}{2}\,\sqrt{7} \right) }$ is $\displaystyle{ \frac{43}{4} -\frac{7}{2}\,\sqrt{7} \sim 1.4897\, }$ , so that $\displaystyle{ \text{dist}\left( y =-\frac{1}{2} -\frac{1}{2}\,\sqrt{7} \right) = \sqrt{ \frac{43}{4} -\frac{7}{2}\,\sqrt{7} } \sim 1.2205\, }$ , and $\displaystyle{ \text{dist}^2 ( y =1 ) }$ is $20\,$ , so that $\displaystyle{ \text{dist}(y=1) =\sqrt{2\,\sqrt{7} } \sim 4.4722\, }$ , the distance $\text{dist}(y)$ is minimized when $\displaystyle{ y =-\frac{1}{2} -\frac{1}{2}\,\sqrt{7} \sim -1.8229\, }$ , and the minimum distance is
$\displaystyle{ \text{dist}\left( y =-\frac{1}{2} -\frac{1}{2}\,\sqrt{7} \right) = \sqrt{ \frac{43}{4} -\frac{7}{2}\,\sqrt{7} } \sim 1.2205\; }$ .
This analysis gives firm support to our experimental observations.