We want to minimize and maximize the function where is the distance from the origin to squared.

The reason we can minimize the distance squared is because is a monotonically increasing function on .

Let's solve .

.

and .

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.