# How to plot absolute value graphs?

I have to plot graph of
$$f(x)=|x|+2|x-1|+|x-4|$$
See I know graphs of individual $$|x|,2|x-1|,|x-4|$$
But how can I draw their sum.
I have to find minimum value of the sum using graph.

Hint: make a case distinction.

1st case: $$x< 0$$

2nd case: $$0\leq x < 1$$

3rd case: $$1\leq x < 2$$

4th case: $$2\leq x$$

In all four cases, you can simplify the expression to a linear function, which yields you the definition of a piece-wise linear function. Plot each of these restricted to the intervals specified by the conditions, and you get the graph.

• I think, this implies that the minimum value lie at one of the points at which individual values are least. Thanks. – Love Invariants Apr 15 at 7:35

If you are interested in a more general solution of what the minimum of your expression is (even without graphs):

Your expression has the generalized form

$$\sum_{k=1}^n|x-x_i|$$

A standard result is that the minimizer of this expression is a median of the data $$x_1, \ldots , x_n$$.

So, in your case the minimum is the median $$m$$ of $$0,1,1,4$$: $$\boxed{m = 1}$$.

• I got it from graph method answered by A.Pongracz. Thanks for proof in the link. – Love Invariants Apr 15 at 8:07