Question:
$$ \text{Define } f:\mathbb{Z}\rightarrow\mathbb{Z}\text{ by }f(x)=\begin{cases}x+3\text{ if }x\text{ is ODD}\\ x-5\text{ if }x\text{ is EVEN}\end{cases} $$
Compute $ \ f \circ f$
My attempt:
$ \ (f \circ f)(x) = f(f(x))$
From here do I have to create another piecewise function and consider the cases when $ f(x) = x+3$ and when $ f(x) = x-5$?
When $x$ is odd $f(x)=x+3$, so $f(x)=x+3$ is even and $f\circ f(x)=f(f(x))=(x+3)-5=x-2$.
When $x$ is even $f(x)=x-5$, so $f(x)=x-5$ is odd and $f\circ f(x)=f(f(x))=x-5+3=x-2$.
Hence $f\circ f(x)=x-2$.