# Expressing absolute value equations as piecewise functions

I'm not sure how to express this function in piecewise form without using absolute values:

$$f(x) = 3|x-2| - |x+1|$$

I know how to do it when there is just one absolute value, such as:

$$g(x) = 3+|2x-5|$$

$$g(x)= \begin{cases} 2x-2& \text{; }x\ge\frac52\\ 8-2x&\text{; }x<\frac52 \end{cases}$$

To express $g(x)$ in piecewise form, I made 2 cases. Case 1 positive and Case 2 negative.

But I can't exactly do that for this problem [$f(x)$]... Could someone tell me how to proceed?

EDIT: Thank you for all the help!

• I would first find where the function is $0$ – illysial Aug 21 '14 at 0:16

The only places where we need to break the function into "pieces" are those points where the expression inside each absolute value becomes zero. This occurs at $x = -1$ and $x = 2$.

Accordingly, we consider what the function looks like on each of the intervals $(-\infty,-1)$, $(-1,2)$, and $(2,\infty)$.

For $x < -1$, we have $x + 1 < 0$ and so $|x+1| = -(x+1)$. Similarly, $x - 2 < x + 1 < 0$ and so $|x-2| = -(x-2)$. So on the interval $(-\infty,-1)$ the function can be simplified as $f(x) = -3(x-2) +(x+1) = -2x+7$.

Thus far, we have established

$$f(x) = \begin{cases} -2x + 7 & \text{if }x < -1 \\ ??? & \text{if }-1 \leq x \leq 2 \\ ??? & \text{if }x > 2 \\ \end{cases}$$

You can handle the other intervals in exactly the same way.

• Fixed my sign error, sorry about that. – Bungo Aug 21 '14 at 0:19
• Ah, I get it, thanks! So would the answer be this? $$f(x)= \begin{cases} -2x+5& \text{if }x<-1\\ -4x+5&\text{if }-1\le x\le2\\2x-7&\text{if }x>2 \end{cases}$$ – Alantin14 Aug 21 '14 at 0:31
• Actually, it seems that there is a miscalculation... Wouldn't the first piece be $-2x+7$ instead of $-2x+5$ ? Or am I wrong? – Alantin14 Aug 21 '14 at 0:42
• @precalculusANON: Looks good to me! One more thing I will mention: note that it doesn't matter where we put the $\leq$ since the $f$ is continuous (because it is the sum of two continuous functions). So we could equally well make the intervals $x \leq -1$, $-1 < x < 2$, and $x \geq 2$ if we were so inclined. – Bungo Aug 21 '14 at 0:42
• @HananN. In this case, it doesn't make a difference. You could make the first interval $x \leq 1$ and the second interval $1 < x \leq 2$ if you prefer. The reason this is OK is because $f$ is a continuous function, so when you express it piecewise, the first and second formulas must have the same value at $x=-1$, and similarly, the second and third formulas must have the same value at $x=2$. – Bungo Feb 12 '16 at 19:46

Try expressing each of the parts - $3|x-2|$ and $|x+1|$ in piecewise form first. This tells you where the behaviour of the function is going to change: at $x=-1$ and $x=2$. So you have three intervals to look at: $\{x < -1\}$, $\{-1 \le x \lt 2\}$ and $\{x \ge 2\}$. Then all you have to do is see how the two functions combine in each of those regions.

• How do you know when the interval include $\leq or \geq$ sign? in other words why in the first interval its $x < -1$ and in the second is $-1 \leq x \leq 2$ ? – Hanan N. Feb 12 '16 at 10:59
• Since |0| = |-0| = 0, you can include that point on either interval. I chose to use intervals that are closed on the left, but you could do it the other way (or mix them up, although I like having a consistent, if arbitrary, choice). – ConMan Feb 14 '16 at 23:57