Find the minimum value of $|x+1|+2|x-5|+|2x-7|+|\frac{x-11}{2}|$

158 Views Asked by At

Find the minimum value of $|x+1|+2|x-5|+|2x-7|+|\frac{x-11}{2}|$.

I have no idea how to approach this question. However, I managed to solve it using a rather childish approach. I change this equation by multiplying $2$, getting $2|x+1|+4|x-5|+4|x-3.5|+|x-11|$. Now, I have a number line, and I mark out $-1$, $3.5$, $5$ and $11$. Here, I shall use this analogy which may seem childish. There are $2$ houses at $-1$, $4$ houses at $3.5$, $4$ houses at $5$, and $1$ house at $11$.

Here, I introduce a train station. We need to place it at an optimum place to minimise the distance from every house to it. If it is between $3.5$ and $5$, observe that it needs to move left to please more people(easier to board train). If it is placed between $-1$ and $3.5$, it needs to move right to please more people. Hence, the optimum place to put the train station would be at $3.5$, hence I have $x=3.5$, which is correct. You guys can draw a diagram to understand better. In addition, I noted that this seemed rather similar to some programming problems.

Back to the question, is there a much more elegant way to this problem?

6

There are 6 best solutions below

2
On BEST ANSWER

Your method is quite handwavy, and while intuitively it may make sense, mathematically, that's no way to solve a problem.

Instead, you can notice that on the intervals $(-\infty, -1]$, $[-1,3.5]$, $[3.5,5]$ and $[11,\infty]$, the function is linear.

Now, a linear function on a closed interval reaches its minimum on one (or both) of the edges, meaning that the minimum of $f$ over $[-1,3.5]$ can only be reached at $-1$ or at $3.5$. Therefore, the minimum of the entire function (if it exists) can only be reached at the points $-1,3.5,5$ or $11$.

Clearly, because $\lim_{x\to\pm\infty} f(x)=\infty$, the function must have a minimum somewhere, so checking the values $f(-1), f(3.5), f(5)$ and $f(11)$ is enough to find the minimum.

4
On

Hint:

to get the minimum value, the each term should be zero, that means $$|x+1|=0$$ or $$|x-5|=0$$ or $$|2x-7|=0$$ or $$|\frac{x-11}{2}|=0$$

find the solution for each term and see which one gives you the minimum

0
On

Generalized version of this problem looks like this: given $a_i$, $w_i \ge 0$ find $x$ such that $f(x) = \sum\limits_{i=1}^n w_i |x - a_i|$ is minimized. Assume that $a_1 < a_2 < \ldots < a_n$. Then $f'(x) = \sum\limits_{a_i < x} w_i - \sum\limits_{a_i > x} w_i = g(x)$ (the derivative exists iff $x \not\in \{a_1, \ldots, a_n\}$). Therefore you need to find $i$ such that $f'(x) \le 0$ for $x \in (a_i, a_{i+1})$ and $f'(x) \ge 0$ for $x \in (a_{i+1}, a_{i+2})$. Note that $g(x)$ is defined everywhere so you need to find $i$ such that $g(a_i) \le 0$ and $g(a_{i+1})\ge 0$.

If all $w_i = 1$ it is equivalent to finding the median of $a_1, \ldots, a_n$.

3
On

Case 1:$x\le -1\\f(x)=-x-1+10-2x+7-2x+5.5-0.5x=21.5-5.5x$

Case 2:$-1\le x\le 3.5\\f(x)=x+1+10-2x+7-2x+5.5-0.5x=23.5-3.5x$

Case 3:$3.5\le x\le 5\\f(x)=x+1+10-2x-7+2x+5.5-0.5x=9.5+0.5x$

Case 4:$5\le x\le 11\\f(x)=x+1-10+2x-7+2x+5.5-0.5x=-10.5+4.5x$

Case 5:$11\le x\\f(x)=x+1-10+2x-7+2x+0.5x-5.5=-21.5+5.5x$

so we have: $$\min_{x\in\Bbb R}f(x)=\min_{x\le-1}f(x)+\min_{-1\le x\le 3.5}f(x)+\min_{3.5\le x\le 5}f(x)+\min_{5\le x\le 11}f(x)+\min_{x\ge 11}f(x)=\min\lbrace{27,11.25,11.25,12,39}\rbrace=11.25$$

here is a sketch:

enter image description here

0
On

May you use the fact that the median, in our case $3.5$, minimizes the arithmetic mean of the absolute deviations, see https://en.wikipedia.org/wiki/Median#Optimality_property ?

0
On

$$ f(x)=|x+1|+2|x-5|+|2x-7|+\left|\frac{x-11}2\right| $$ is linear on each segment $$ \overbrace{(-\infty,-1]\vphantom{\frac72}}^{m=-\frac{11}2},\overbrace{\left[-1,\frac72\right]}^{m=-\frac72},\overbrace{\ \left[\frac72,5\right]\ }^{m=\frac12},\overbrace{\ \ [5,11]\ \ \vphantom{\frac72}}^{m=\frac92},\overbrace{\ [11,\infty)\ \vphantom{\frac72}}^{m=\frac{11}2} $$ Thus, the minimum is at $x=\frac72$, where the slope changes from negative to positive. That is, the minimum is $$ f\!\left(\frac72\right)=\frac{45}4 $$