4

If $a<b<c<d$ and $x\in\mathbb R$ then what is the least value of the function $$f(x)=|x-a|+|x-b|+|x-c|+|x-d|\ ?$$

$f(x)= \begin{cases} a-x+b-x+c-x+d-x & x\leq a \\ x-a+b-x+c-x+d-x & a< x\leq b \\ x-a+x-b+c-x+d-x & b< x\leq c \\ x-a+x-b+x-c+d-x & c< x\leq d \\ x-a+x-b+x-c+x-d & x> d \end{cases}$

then $f'(x)=\begin{cases} -4 & x\leq a \\ -2 & a< x\leq b \\ 0 & b< x\leq c \\ 2 & c< x\leq d \\ 4 & x> d \end{cases}$

From here on,i am stuck.Help me out

user26857
  • 52,094
  • 1
    A quick note, the way you wrote $f'(x)$ seems to imply that $f'(b)$ is simultaneously equal to $-2$ and $0$. Similarly $f'(a),f'(c),f'(d)$ have problems. We would say that the derivative does not exist at these points. – JMoravitz Aug 15 '15 at 07:08

1 Answers1

5

HINT: Forget derivatives. The number $f(x)$ is just the sum of the distances from $x$ to $a,b,c$, and $d$. Imagine starting $x$ somewhere to the left of $a$ and moving it to the right. Initially all four of the terms are decreasing. When $x$ passes $a$ and starts moving on to $b$, the distance from $x$ to $a$ increases, but the distance from $x$ to $b$ decreases at the same rate, so $|x-a|+|x-b|$ is constant. The distances from $x$ to $c$ and $d$ are decreasing, so $f(x)$ is still decreasing. Now continue this analysis as $x$ continues to move to the right.

Try to finish it on your own. If you get completely stuck, there's more information in the spoiler-protected block below.

The function is decreasing to the left of $b$, constant on the interval $[b,c]$, and increasing to the right of $c$, so its minimum value, in terms of $a,b,c$, and $d$, is ... ?

Brian M. Scott
  • 616,228
  • 1
    $c+d-a-b$ is the answer,right? – mathspuzzle Aug 15 '15 at 07:35
  • 2
    @mathspuzzle: Yes: when $b\le x\le c$, the sum of the distances from $x$ to $a$ and $d$ is $d-a$, and the sum of the distances from $x$ to $b$ and $c$ is $c-b$, so the total is indeed $c+d-a-b$. – Brian M. Scott Aug 15 '15 at 07:46
  • Wow! Your answer is very interesting! We could also say: when we move $x$ between $a$ and $d$, sum of the distances from this point to $a$ and to $d$ is constant. So in order to have minimum distance to $b$ and to $c$, the point should be on the interval $[b,c]$ – Etemon Feb 18 '21 at 16:31
  • And more generally we can conclude a point has minimum sum of distances to two specific points if it is between them (or on one of them). Here for four points we have two pair of points $a,d$ and $b,c$, so for $x\in[b,c]$ we have minimum sum of distances ;) – Etemon Feb 18 '21 at 16:46