The reason we can minimize the distance squared is because is a monotonically increasing function on .
Let's solve .
This means is a local minimum and is a local maximum.
Now to check the endpoints. .
Therefore and are the points in that minimize the distance to the origin.
Also the point maximizes our desired distance.