# Composition of Two Real Piecewise Functions

I am trying to determine the function $f \circ g$ where

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

and

$$g(x) = \begin{cases} x-2, & \text{if }x\ < -1 \\ -x, & \text{if }-1 \leqslant x\leqslant 1 \\ x+2,& \text{if }x > 1 \end{cases}$$

I understand function composition. The problem I am having here is that I don't know how to determine what happens to the input of $f$ from the output of $g$. I am not looking for the answer, I just need understand exactly how a composition of piecewise functions works. I haven not been able to obtain anything useful from other sources. I really don't know where to start solving this exercise. Is there anybody that has any valuable input they can give me?

For example. Let's say we want $f(g(x))$ for $x<-1$, then we have $f(g(x)) = f(x-2)$ since $g(x) = x-2$ for $x<-1$. Now since $x<-1$, this means that $x-2<-3$ which means that $f(x-2) = (x-2)+2 = x$. Now proceed with the other cases.
• Thank you! What about the case $f(-x)$? Since $-1 \leqslant x \leqslant 1$, does this mean that $1 \geqslant -x \geqslant -1$ ? Mar 1, 2013 at 3:30
First split up the inputs to the composite function according the the cases for $g$. Within each case, look at the outputs: are they all in one of $f$’s cases, or not? If they are, life is simple: $f\circ g$ will have the same cases as $g$. If not, you’ll have to subdivide $g$’s cases.
Here, for instance, consider the case $x<-1$: $g(x)=x-2$, so $g(x)<-1$ for all $x<-1$, and calculating $(f\circ g)(x)$ will require using the first case of $f$. Something similar happens in the other cases, so with this pair of functions you won’t actually have to do and subdividing.