, f(x) = |x-1| + |x-2| + |x-3| +
|x+4|. Note that finding the value of x which minimizes f finds the point
in [-10, 10] which is closest to the points 1, 2, 3, -4.
The endpoints of the domain of f are the -10 and 10, so the extreme values may occur at either x = -10 or x = 10.
f has no derivative at 1, 2, 3, and -4, so the extreme values of f may occur at any of these four values of x.
Otherwise, since |u|' = u/|u| the chain rule gives
![]()
Now we compute f at each of the candidate locations: f(-10) = 42, f(10) =
38, f(-4) = 18, f(1) = 8, f(2) = 8, f(3) = 10 and f(x) = 8 if
. We conclude that the maximum value of f is 42 and the minimum
value is 8. Hence the range of f is [8,42]. Note that this could have
been obtained easily from the graph of y= f(x), but the general problem,
, f(x) = |x-a| + |x-b| + |x-c| +
|x-d| cannot be solved graphically if the values of a,b,c,d are not
specified, while it can be solved analytically, although without calculus if
one is clever enough.
Note also that if we have change the rule of f to f(x) = |x-1| + |x-2| +
|x-3| + |x+4| + |x+6|,
for every x.
,

f is clearly continuous, so its extreme values may occur at -3 and 3. As far as differentiability is concerned, the only point that is a mystery is x = 0. However, we can easily check that


,


![]()
