Minimize function $\sqrt{x^2-4x+5}+\sqrt{4+x^2}$

112 Views Asked by At

Suppose I want to find $$ \min f(x) = \min(\sqrt{x^2-4x+5}+\sqrt{4+x^2}) $$ I'd start with computing derivative and set it to $0$ $$ f'(x) = \frac{x-2}{\sqrt{x^2-4x+5}} + \frac{x}{\sqrt{4+x^2}} $$ Then $$ \frac{x-2}{\sqrt{x^2-4x+5}} + \frac{x}{\sqrt{4+x^2}} = 0 $$ $$ (x-2)\sqrt{4+x^2} + x\sqrt{x^2-4x+5}=0 $$ My first instinct is to rewrite it as $$ (2-x)\sqrt{4+x^2} = x\sqrt{x^2-4x+5} $$ and square both sides. The thing is, I get $$ 3x^2 -16x +16=0 $$ with $x_1 = 4/3$ and $x_2 = 4$. So $f'(x_1^-) <0$ and $f'(x_1^+) > 0$ thus in $x = 4/3$ there is a minimum of our function.

Question: is it valid to square both sides of an equation as I did above? Is there a possibility that because of that I lose or introduce a solution that shouldn't exist and might mess everything up?

4

There are 4 best solutions below

0
On

Squaring both sides gives you the solutions to $(2-x)\sqrt{4+x^2} = x\sqrt{x^2-4x+5}$ and to $(2-x)\sqrt{4+x^2} = -x\sqrt{x^2-4x+5}$. So if our possible candidates are $x = 4/3, 4$, we can substitute these values into the equation before squaring.

We find that only $x_1 = 4/3$ satisfies the original equation.

Of course it remains to check that $(x_1, f(x_1))$ is a minimum. Therefore $f(x)$ has exactly one minimum point and no other extrema, as the graph confirms:

enter image description here

0
On

Analytically, I regard your method as partially valid.

Once you square both sides, you get a quadratic with two roots. So, you then have to manually check each root against the original equation to determine which root (if any) is not extraneous.

That is, if you get roots $x_1,x_2$ that are both real numbers, then you have to manually check whether $f'(x_1) = 0$ and whether $f'(x_2) = 0.$

Once you determine all of the values $x$ such that $f'(x) = 0$, you then have two choices to analytically complete the problem.

Assuming (for example) that $f'(x_1) = 0 = f'(x_2)$, you would then need to compute $f''(x_1)$ and $f''(x_2)$. If (for example) you are focusing on both $x_1$ and $x_2$, and if both corresponding 2nd derivatives are non-zero, then you can complete the analysis.

That is, for any value of $x_0$, if $f'(x_0) = 0$ and $f''(x_0) > 0$, then $f(x)$ has a local minimum at $x = x_0$. If $f''(x_0) < 0$ then $f(x)$ has a local maximum at $x = x_0$.

Assuming (for example) that you know that $f(x)$ only has the two critical points $x_1, x_2$, then, if the above paragraph is pertinent, you are done.

Sometimes, computing the 2nd derivative is problematic, either because the expression is very complicated, or because the corresponding 2nd derivative is also equal to zero.

Assume that that is the case, with $x_1 < x_2$. Then, you could complete the problem by simply manually computing $f(x_1)$ and $f(x_2).$ This would then allow you to validly draw a conclusion.


As indicated by the comment of abiessu, an alternative approach that may be easier is to find convenient points $x_a, x_b, x_c$ such that $x_a < x_1 < x_b < x_2 < x_c.$

Without doing any interrogation of which of (for example) $x_1,x_2$ are extraneous roots that do not satisfy $f'(x) = 0$, you could manually compute the five values of $f(x_a), f(x_1), f(x_b), f(x_2), f(x_c)$. After doing this, then (again), you can draw the necessary valid conclusion.

This is because, although you are unsure (at this point) whether $x_1$ and/or $x_2$ satisfy $f'(x) = 0$, you are guaranteed that no other value of $x$ can satisfy $f'(x) = 0.$

In effect, by computing the $5$ points manually, you are metaphorically graphing the function, as suggested by abiessu.

0
On

You can square, but only after ensuring that you're equating numbers that are either both positive or both negative.

In your case you have $$\textstyle (2-x)\sqrt{4+x^2}=x\sqrt{x^2-4x+5} $$ The square roots give no problem: they are both defined anywhere and positive. The sign is determined by the other factors.

If $2-x\ge0$, we also need $x\ge0$, that is, $0\le x\le2$.

If $2-x\le 0$, we also need $x\le0$, but this cannot happen.

Thus we can square, but we must discard roots that are not in $[0,2]$.

The equation you get is indeed $3x^2-16x-16=0$, with roots $4/3$ and $4$. The latter must be discarded.


By the way, the problem can be solved in a different way. Your function is \begin{align} f(x) &=\textstyle\sqrt{x^2+4}+\sqrt{(x-2)^2+1^2} \\[6px] &=\textstyle\sqrt{(x-0)^2+(0-2)^2}+\sqrt{(x-2)^2+(0-(-1))^2} \end{align} which is the sum of the distances of a point on the line $x=0$ from the points $(0,2)$ and $(2,-1)$.

You don't even need to compute the point of minimum, because the minimum is the distance between the two points, hence $$\textstyle \sqrt{(0-2)^2+(2+1)^2}=\sqrt{4+9}=\sqrt{13} $$

If you want to find the point of minimum, the line joining the two points has equation $$ \frac{y+1}{2+1}=\frac{x-2}{0-2} $$ The only point $(x,0)$ on the $x$-axis satisfies $$ \dfrac{1}{3}=\dfrac{2-x}{2} $$ hence $x=4/3$.

enter image description here

0
On

I want to get to your fundamental question about what operations increase or decrease your set of solutions, which may add solutions that don't actually solve the original equation or omit valid solutions to the original problem:

Getting extra solutions happens when you apply a function which is not injective. A function is called injective when for every value in the codomain (the values it could take on), there is at most one value in the domain (the inputs), which maps to it. So if you have two different values $x$ and $y$ such that $f(x) = f(y)$, then $f$ is not injective.

You can easily see that taking the square, which is just the function $f_1(x) = x^2$, is not injective, hence you get an extra solution which doesn't actually solve your original equation. In fact, it will give you some value $a$ on one side and $-a$ on the other side of the equation. The only exception to this is when both sides were $0$ anyway. The function $f_a(x) = a \cdot x$ (for some $a$) is injective as long as $a$ is non-zero. You will see why I mention this in a second.

On the other hand, losing a solution happens when you apply the inverse of a function which is not injective. Notice that the function (call it $f$) not being injective means the inverse (call it $g$) is technically not a function, since if $x$ and $y$ both map to $f(x) = f(y) = z$, then we cannot define $g(z)$ as both $x$ and $y$.

To make it more specific, take the square root "function". The square root is the inverse of the function $f_1(x) = x^2$, which we saw above is not injective. We turn the square root into a function by taking just the positive roots, but that's where you lose information.

Another example is when dividing by a term on both sides in an equation of the form $a\cdot b = a\cdot c$, where $a$ could take on the value $0$ and if you just cancel on both sides, you lose that as a solution (here $a,b,c$ should be considered terms/functions, not simple variables). Multiplying by a non-zero number $a$ doesn't change your set of solutions because, as we saw above, it is injective. It's inverse, which is multiplying by $\frac{1}{a}$, is the same operation with a different non-zero number and hence doesn't change the set of solutions either, as we expected. But when $a=0$, $f_a(x)$ is no longer injective and it's inverse is no longer a well-defined function, so trying to apply it (usually hidden by dividing by a term which equals $0$ rather than just dividing by the number $0$) will reduce your set of valid solutions.