Consider the graph of , the sum of the distances from a point on the number line to and to .
The candidates for corners are the values where an absolute value changes sign, namely and .
| Range | Expression with the absolute values removed | Result | Slope |
|---|---|---|---|
The corners are at and , and the flat bottom between them is the minimum value .
The value is obvious once distance is the picture. Stand anywhere between and and the two distances add up to exactly the gap between the points, which is . Step outside and you walk that excess twice over, so the sum can only grow. In symbols this is the triangle inequality.
Equality holds precisely on .
What makes this function interesting is that the minimum is attained not at a point but along a whole interval. Anywhere from to , the sum of distances stays at . That flat bottom is the signature of a sum of absolute values.
The solutions of can be read off the same shape.
| Range of | Solutions |
|---|---|
| none | |
| every point of , infinitely many | |
| two, one on each outer arm |
Raising and lowering the horizontal line changes the solutions in this way.
Minimizing a sum of distances is a common problem in applications. On the number line, the point minimizing the total distance to several given points is their median; with an even number of points, anywhere in the interval between the middle two will do.
| Quantity minimized | Optimal position |
|---|---|
| Sum of squares | the mean |
| Sum of absolute values | the median |
The robustness of the median against outliers is written right here, in this flat bottom. The large dots mark the corners and the middle point .