# What ranges to take while finding composition functions

A function is defined as $$f(x)=\begin{cases}-x,&\quad x<0\\x,&\quad 0\le x\le 1\\2-x,&\quad x>1 \end{cases}$$

How to find composite function function $f(f(x))$?

I can't understand what ranges are to be taken while evaluating the composition.

You should just walk through without thinking too much if you have a problem: If $x < 0$, $f(x) = -x > 0$. This means we need to account for the cases $0 \le -x \le 1$ and $-x > 1$, the former giving $f(f(x)) = -x$ for $-1 \le x < 0$ and the latter $2-(-x) = 2+x$ for $x < -1$. This already gives us the components $$f(f(x)) = \begin{cases} 2+x & x < -1 \\ -x & -1 \le x < 0 \\ ? & \text{else}\end{cases}$$ Proceed by walking through the other two cases for the inner $f(x)$ in a similar way.