Minimizing distance fails? This may seem like a stupid question. Let's say I want to minimize the distance from $\left(0,0\right)$ to the function $f\left(x\right)=\sqrt{x^2-4}$. 
I know how to do this using Calculus, but it always fails: $d=\sqrt{\left(x-0\right)^2+\left(y-0\right)^2}=\sqrt{x^2+\left(\sqrt{x^2-4}\right)^2}=\sqrt{2x^2-4}$. 
When I minimize the resulting function, I receive $x=0$, which isn't even in the domain of $f$, and it even yields an imaginary distance of $2i$.
Obviously, the answers are $x=-2,2$, and the points are $\left(-2,0\right)$ and $\left(2,0\right)$ yielding a distance of $2$. 
Is the reason why this is failing due to the fact that my point(s) in need is an endpoint of the function?
I've realized that similar functions do the same thing. For instance, if I want to find the minimum distance from $\left(0,0\right)$ to $f\left(x\right)=\sqrt{x-1}$ it fails, but if I choose a point like $\left(4,0\right)$, it works fine. Any rationale for this?
Thanks.
 A: You want to minimize the function 
$$ D(x) = 2x^2 - 4 $$
in the domain $|x| \in [2,\infty] $
The derivative is 
$$ D'(x) = 4x $$
which is zero only at $x=0$, outside our domain. It is always positive in $[2,\infty)$, meaning the distance is strictly increasing over $[2,\infty)$ and therefore must have a local minimum at $x=2$
In $(-\infty,-2]$ the signs are reversed, so $D(x)$ must be decreasing on this interval, achieving a minimum at $x=-2$.
By inspection, $D(2)=D(-2)$, so these are both minimum points.
Overall, this is a helpful exercise to show that there's sometimes more to be done than taking the derivative.
A: Comment written as answer:
A maximum or minimum of a function occurs where the derivative is 0 or where the derivative does not exist.  Yes, setting the derivative equal to 0 gives x= 0 which, as you say, is not a valid answer because f(0) does not exist.  So, instead, any maximum or minimum is where the derivative does not exist.  Since the derivative involves $\sqrt{2x^2- 4}$ in the denominator, the derivative does not exist when $\sqrt{2x^2- 4}= 0$ which is x= 2 and -2.
