Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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} $$


$$ 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?

share|cite|improve this question
up vote 2 down vote accepted

You can do this with cases.

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.

share|cite|improve this answer
Thank you! What about the case $f(-x)$? Since $-1 \leqslant x \leqslant 1$, does this mean that $1 \geqslant -x \geqslant -1$ ? – Doug Ramsey Mar 1 '13 at 3:30
Yeah you have the right idea. – joshphysics Mar 1 '13 at 3:55

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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.