# Maximum and minimum of of $f(x)=|x-1|+|x-2|+|x-3|$

I am trying to find the maximums or minimums of $$f(x)=|x-1|+|x-2|+|x-3|$$ (if there exist).

My attempt: First I compute the derivative and tried to find critical point, i.e, $f'(x) = \frac{x-1}{|x-1|} + \frac{x-2}{|x-2|} + \frac{x-3}{|x-3|}=0$, first I noted that this derivative doesn't exist in 1,2,3 for the absolute value. And the are no critic point (Is that correct?)

Then I stuck here because I don't know if there is a maximum, I think that it is not exist but how can I justified and I believe that there is a global minimum, but this occurs only if I found a critical point, some help pls.

• As far as I know, there isn't an absolute value function in MathJax... Just use vertical bars. The keyboard symbol | works fine, and I think the MathJax equivalent is \vbar, but don't quote me on that – Brevan Ellefsen Apr 25 '16 at 21:15
• Ok, I will do it, ty – Knight Apr 25 '16 at 21:15
• Thre is no maximum, and there is a global minimum at x=2 – Brevan Ellefsen Apr 25 '16 at 21:19
• But the derivative doesn't exist in 2 because the lateral limits exist but are different in this case -2,2 the same occurs with 1 and 3 – Knight Apr 25 '16 at 21:21
• "Critical points" means either the derivative is zero or the derivative doesn't exist. You already concluded the derivative is never zero (quick proof: each absolute value has derivative $+1$ or $-1$ on some interval, and all combinations will result in an ODD number, so never zero.) So all you need to do for a minimum is to check at 1, 2 and 3. There is no maximum since $f$ is unbounded. – mathguy Apr 25 '16 at 21:25

From the fact that $|x|=\pm x$ depending on the sign of $x$, you can infer that the given function is continuous and piecewise linear.

A linear function has no critical points and achieves its minimum/maximum value at the endpoints of its definition domain.

We have $f(-\infty)=\infty,f(1)=3,f(2)=2,f(3)=3,f(\infty)=\infty$. You should be able to conclude.

An extremum can arise at a point that has no derivative: it suffices that the function be continuous, increasing on one side and decreasing on the other, i.e. have derivatives of opposite signs.

For positive $x \geq 3$ the function simply becomes $y = (x-1) + (x-2) + (x-3) = 3x-6$. (this holds because everything is positive!)
For $2\leq x \leq 3$ we get $y= (x-1)+(x-2) + (3-x) = x$. (note that when the inside of the absolute value is negative we can remove the absolute value by taking the opposite of the inside, I.e $|n-k| = (k-n)$ when $k \geq n$ and equals $(n-k)$ when $n\geq k$)
Keep analyzing the function in intervals this way and find the minimums, then compare! You'll find a global minimum at $x=2$

Note: While there are no points where the derivative is zero, remember that when finding critical points on an interval you check everywhere the derivative is zero, the derivative does not exist, and the endpoints!

We have $$f(x)=|3-x|+|x-1|+|x-2|\geq |3-x+x-1|+|x-2|=|2|+|x-2|\geq2$$ using the triangle inequality. But also $f(2)=2$. So it is a minimum.

• That doesn't tell us about the maximum. – Yves Daoust Apr 26 '16 at 7:44