# Absolute Value functions => Piecewise Function

Gold Member
Given the function:

$$f(x) = \left| {x + 1} \right| + \left| {x + 2} \right|$$

How can i write that as a piecewise function? If i was given something in the form of $$f(x) = \left| {g(x)} \right|$$, i know to write it as:

$$f(x) = \left\{ {\begin{array}{*{20}c} {g(x),} & {g(x) \ge 0} \\ { - g(x),} & {g(x) < 0} \\ \end{array}} \right.$$

but im a little stuck with the other one.

Thanks in advance,
Dan.

## Answers and Replies

consider the cases, x+1<0, x+2<0 and other combinations separately:

x+1<0, x+2<0
x+1<0, x+2>0
x+1>0, x+2<0
x+1>0, x+2>0

notice that some of these conditions are impossible.

Gold Member
Hmm ok. So when both are positive $$x + 1,x + 2 \ge 0$$, the piece is $$(x + 1) + (x + 2) = 2x + 3$$. They are both positive only when $$x \ge - 1$$, so my piece ($$2x + 3$$) would only be existant over the domain $$x \ge - 1$$? Is that the way i should go about it?

yes, that should be correct.

Gold Member
Ok thanks for that :)

Gold Member
Just one more thing. Using $$y = \left| x \right|$$ for example. At x=0, it could go either way. y could equal x or -x, so either of the following could be true:

$$\begin{array}{l} f(x) = \left\{ {\begin{array}{*{20}c} {x,} & {x \ge 0} \\ { - x,} & {x < 0} \\ \end{array}} \right. \\ f(x) = \left\{ {\begin{array}{*{20}c} {x,} & {x > 0} \\ { - x,} & {x \le 0} \\ \end{array}} \right. \\ \end{array}$$

Does it matter which way i do it? Or is there some convention i should follow?

HallsofIvy
Science Advisor
Homework Helper
The convention is that |x|= x for $x\ge 0$ but, in fact, either that or |x|= -x for $x\le 0$ give the same function.

Last edited by a moderator:
Gold Member
Ok thanks.

Another way to do it is to find your critical points, (x=-1 and x=-2 in this case) and create an x, f(x) table to test points outside of and between those points within the function. Then you can take the points in the three regions and find the equation of the line between them which is the equation that satisfies the x value of the region it was determined from. A calculator that can come up with a table of values for you really helps with this.