# Why does a distance and its square reach their minimum at the same point?

There is a question in my calculus textbook that asks to find a point on the parabola $y^2 = 2x$ that is closest to point $(1,4)$.

They want us to first use the distance formula, but then proceeded to square it leaving us with $d^2 = (y^2/2 - 1)^2 + (y-4)^2$.

I am following the math up to this point, where I get lost is when the textbook states "You should convince yourself that the minimum of $d^2$ occurs at the same point as the minimum of $d$, but $d^2$ is easier to work with".

I don't understand how that can be true at all, $d$ is a distance between a fixed point and another point on the graph $y^2 = 2x$. $d^2$ must be that distance scaled by itself, how can the minimum be the same then? I've worked out the math for $d$ and $d^2$ and I do get the same point but I don't understand why.

• Um.. if $0 \le x \le y$ then $0 \le x^2 \le y^2$. That is all there is too it! If $\min d$ occurs at $x_1$ and the $\min d^2$ occurs at $x_2$ we have $d(x_1) \le d(x_2)$ and $d^2(x_2) \le d^2(x_1)$. But if $d(x_1) \le d(x_2)$ then $d^2(x_1) \le d^2(x_2)$. so $d^2(x_1) = d^2(x_2)$ and $d(x_1) = d(x_2)$. May 2, 2016 at 19:16
• The minimum does not have the same value, it occurs at the same point. What your textbook means is: if the minimum value of $d$ is $d_{min}$, then the minimum value of $d^2$ is $d_{min}^2$ May 3, 2016 at 7:30
• The square and square root functions are strictly monotonic increasing for positive values. This means that if input increases, output always increases. So anything that is not minimal for one of them can't be it for the other either. May 3, 2016 at 8:42
• Just dropping in to mention that all distance functions, whether euclidean or not, are positive-definite, while lots of numbers can be negative or complex. Therefore when you square something, you're essentially calculating a vector's distance/length and QED. May 3, 2016 at 17:32
• To put all of the below answers into a quip: "BIG SQUARE/BIG SIDE". May 3, 2016 at 21:59

If you want to figure out which of $\sqrt{2}$ and $\sqrt{3}$ is the smallest, you can do this simply by comparing $2$ and $3$ instead. More generally, if you want to make a square root as small as possible, you can do this by making what's under the square root as small as possible.

• Seems the most easily understandable and concise answer. May 3, 2016 at 19:14
– JM97
May 9, 2016 at 6:03

This has nothing to do with derivatives, nor epsilons; it's pure logic.

If you have a function $f:\>P\to{\mathbb R}_{\geq0}$ defined on some set $P$ (like a parabola in the plane) and a strictly increasing function ${\rm sqr}:\>{\mathbb R}_{\geq0}\to{\mathbb R}_{\geq0}$ then the function $$g:={\rm sqr}\circ f:\quad P\to{\mathbb R}_{\geq0},\qquad x\mapsto{\rm sqr}\bigl(f(x)\bigr)$$ satisfies $$g(x)>g(y)\quad\Leftrightarrow\quad f(x)>f(y)\qquad\qquad\forall x,\>y\in P\ .$$ It follows that the functions $f$ and $g$ take their extrema at the same points of $P$.

• "This has nothing to do with derivatives, nor epsilons", no, but it has to do with linearization and deltas! :p May 2, 2016 at 21:15
• Rather than logic, I would say that it follows from the fact that $x\mapsto x^2$ is increasing on $[0,+\infty)$. May 3, 2016 at 8:33
• @Tom-Tom: Even shorter: Look! An order-isomorphism! May 3, 2016 at 12:37

If $x \ge 0$ and $y \ge 0$ then $x \le y \iff x^2 \le y^2$.

So as distances are greater or equal to 0, a distance is smaller or equal to another if and only its square is smaller or equal to the other's square.

So as $\min distance$ (in terms of $x$) is the smallest possible value, it will occur at the same $x$ where the $\min distance^2$, the smallest possible value of the squares, occurs.

That's all there is to it.

This isn't a rigorous explanation, but one that will hopefully intuitively make sense.

Suppose that you are minimizing the distance between some curve $f(x)$ and a point $(x_0,y_0)$. We might not know what that minimum distance is, but we know that it is some value $d$, where $d\in\mathbb{R}$. Since we are assuming that $d$ is the minimum value, we know that all other points on $f(x)$ will be further away from $(x_0,y_0)$ and thus their distances from the point will be $d+\epsilon$, where $\epsilon\in\mathbb{R^+}$.

Now we will compare our minimum distance $d$ with the other distances $d+\epsilon$ by squaring each.

$$d^2=d^2$$ $$(d+\epsilon)^2=d^2+2d\epsilon+\epsilon^2$$

Since $\epsilon$ is a positive value, we can say for certain that $d^2<d^2+2d\epsilon+\epsilon^2$, and therefore working with the square of the distance will still result in finding the minimum distance.

Suppose I have two boxes, one with $M>0$ dollars, one with $N>0$ dollars. I don't tell you what $M$ and $N$ are, but only that $M^2 > N^2$. Which box has more money? The box with $M$ dollars, because when comparing two positive numbers, it suffices to compare their squares. The one with the larger square is larger.

• OK, but what about calculating a closest point on a parabola where $x$ or $y$ is negative? May 3, 2016 at 17:33

Distances are positive real numbers. $f(x) = x^2$ is strictly increasing on the set of all positive real numbers. So $d_1 \le d_2$ if and only if $d_1^2 \le d_2^2$.

## Using derivatives.

Suppose $d(x) = \sqrt{f(x)}$.

If $d(x_0) = 0$ for some $x_0$, then we know that a minimum is at $x_0$.

So, from here on, we can assume that $d(x) > 0$ for all $x$.

computing directly, we get \begin{align} d'(x) &= 0 \\ \dfrac{f'(x)}{2\sqrt{f(x)}} &= 0 \\ \dfrac{f'(x)}{2d(x)} &= 0 \\ f'(x) &= 0 \end{align}

Or, if we do it this way: \begin{align} (d^2(x))' &= 0 \\ f'(x) &= 0 \end{align}

So, either way, you end up solving $f'(x) = 0$

In this case: you want distance between $\;(x,2x)\;,\;\;(1,4)\;$

$$\begin{cases}d(x)=\sqrt{(x-1)^2+(2x-4)^2}\implies d'(x)=\frac{(x-1)+2(2x-4)}{\sqrt{(x-1)^2+(2x-4)^2}}\\{}\\d^2(x)=(x-1)^2+(2x-4)^2\implies (d^2)'(x)=2\left[(x-1)+2(2x-4)\right]\end{cases}$$

Can you see now that searching for the point where the derivative vanishes is the same in both cases?!

Thus

$$(d^2)'(x)=0\iff5x=9\iff x=\frac95...\text{etc.}$$

The first thing you should notice is that a distance is a positive number. Suppose the minimum distance is $d_{\text{min}}$. The statement means that any other distance $d$ is larger that $d_{\text{min}}$: $$d\geq d_{\text{min}}.$$ As distances are positive, the squares are ordered in the same way $$d^2\geq d_{\text{min}}^2.$$ You can convince yourself by remarking that the area of a square grows when the size of the square grows. This proves the statement.

• Note that when one get experimented in geometry, minimizing the squared distance instead of the distance is a convenient way to reach the result, because, as a distance is always positive, this leaves no ambiguity on the result. May 3, 2016 at 8:32

Simply put,

$$\frac{d(y^2)}{dx} = 2 y \frac{dy}{dx} = 0$$

and

$$\frac{d y}{dx} = 0$$

have the same latter condition to be fulfilled to find an extremum.

And that goes for any square function of x !!

If you only care about the locations of minima and maxima, the derivative chain rule can make this easier. Say you have a function $f(x)$ that you want to maximize/minimize. In your case, this would be the distance formula $d = \sqrt{\Delta x^2 + \Delta y^2}$. Very often, there is another function that considerably simplifies the derivative. Call that function $g(x)$. In this case, $g(x) = x^2$. I will show the result for general functions $f$ and $g$ since it is not always the case that squaring a function makes it simpler.

Now, let's see how the extrema of $g(f(x))$ compares with $f(x)$.

$$\frac{d}{dx}g(f(x)) = \frac{dg}{df} \frac{df}{dx} = 0$$ So, the derivative of $g(f(x))$ has the same zeros as $f(x)$ as long as the derivative of $g(x)$ meets one of two conditions:

• It is non-zero everywhere in the relevant range of $x$, or
• It is equal to zero only when $df/dx$ is also equal to zero.

Now we need to check that the second derivative of $g(f(x))$ has the same sign as the second derivative of $f(x)$ so that the minimas and maximas aren't switched.

$$\frac{d^2}{dx^2}g(f(x)) = \frac{d}{dx}\left(\frac{dg}{df} \frac{df}{dx}\right) = \frac{dg}{df} \frac{d^2f}{dx^2} + \frac{df}{dx} \frac{d}{dx}\left[\frac{dg}{df}\right]$$ $df/dx$ is zero at the extrema, so the second derivative is $$\frac{dg}{df} \frac{d^2f}{dx^2}$$ If the derivative of $g(x)$ is strictly positive over the range of x we are examining, then the second derivative will have the same sign.

For your problem, $g(x) = x^2$, which has a strictly positive first derivative except at $x = 0$. But, the minimum possible distance in any situation is zero, so the exception doesn't add any new extrema. We can conclude that any point that minimizes the squared distance will also minimize the distance.

Sometimes a picture's worth a thousand words.

But as it has been pointed out, some words may also be useful.

The blue plot is the distance function. It may seem redundant, but when two points are distant from $\;x\;$, their distance is $\;x\;$. So here, $\;d\;$ is the distance function, and $\;d(x) = x\;$.

The green plot is the distance squared (when two points are distant from $\;x\;$, their distance squared is $\;d(x)² = x²\;$).

We see that whatever range for the distance, within that range, the distance squared always takes its minimum at the same point as the distance.

• What is the use of the blue line? May 3, 2016 at 16:24
• I'm afraid you're going to have to add some words to explain your picture. I think the only people that will understand what it means are those who already understand the answer to the question. May 3, 2016 at 22:07
• Tried to add some explanations, but yeah maybe it is too intuitive an representation to be useful for one who hadn't already understood May 4, 2016 at 8:19

There is a term called monotonic. A monotonic function doesn't change direction -- as its input grows, it either never-shrinks or never-grows.

A "strictly monotonic" function is a monotonic function that never stays the same -- it always either grows or shrinks.

On the positive real numbers, squaring is a strictly increasing monotonic function.

There are a number of ways to know this. One of them is that the derivative of $x^2$ is always greater than zero on every positive real.

If you have any strictly increasing monotonic function $f$ on some domain containing $x$ and $y$, then comparing $f(x)$ with $f(y)$ is the same as comparing $x$ with $y$ with $\lt$.

We can prove this quickly:

If $y \gt x$, then $\delta = y-x \gt 0$. Thus $f(y) = f(y-x+x) = f(x+\delta)$. As $\delta \gt 0$, as $f$ is strictly monotonically increasing, $f(x+\delta) \gt f(x)$ by the definition of strictly monotonically increasing. A similar argument holds if $y \lt x$.

All that remains to show is that either $x^2$ is strictly monotonically increasing on the non-negative reals, or that a continuous function with a strictly positive derivative on the interior of a continguous interval is strictly monotonically increasing.

The second implies the first, and can be covered in a solid first year calculus class. If I remember rightly, use the greatest lower bound property of the reals on the set of elements $L_x := \{y | y > x\} \cup \{y | f(y)<f(x)\}$ then derive a contradiction based on the limit definition of the derivative.

I think you are mixing up two things. The value/point $(x,y)$ for which the $d(x,y)$ and $d²(x,y)$ are minimal and the actual value of $d$ and $d²$ for $(x_{min},y_{min})$. The value for which d and $d^2$ are minimal is the same, as distance is always positive $d>0$ hence multiplying it with $d$ will result in $d^2>0$ Both expressions are equivalent in this chase with respect of minimum and maximum. But the values $d²$ and $d$ are obviously different.

Put simply - If $d$ is increasing then $d^2$ is increasing. If $d$ is decreasing then $d^2$ is decreasing. Therefore the maximum point of $d$ must coincide with the maximum point of $d^2$. In a formal sense one might have to have d defined on a compact set so that the maximum existed.

I believe answers do explain it intuitively, I will just note down a slightly different way;

Let $$h(x)$$ be strictly increasing. Then $$f(x)$$ and $$h(f(x))$$ has the local extremas at the same point.

$$(h(f(x)))' = h'(f(x))f'(x)$$ and strictly increasing means $$h'>0$$. Therefore, $$f'=0$$ or DNE hold true iff with $$(h(f))'=0$$ or DNE. Moreover, sign of $$f'$$ has to be the same for $$(h(f))'$$. This concludes they have critical points at the same points and classifications do coincide.