What is the inverse of this two-case function? Given the function $f: \mathbb{Z} \to \mathbb{Z}$ defined by 
$$
f(n) = \begin{cases} 
       n+2 \mbox{ if $n$ is even }\\ 2n+1 \mbox{ if $n$ is odd } \end{cases} $$
find the inverse or show that no inverse exists. I found an inverse for each of the cases, but I'm not sure if it is correct.
$$f^{-1}(n) = \begin{cases} n-2 \mbox{ if $n$ is even }\\ \frac{n-1}{2} \mbox{ if $n$ is odd } \end{cases} $$
On a side note, is there a term that decribes functions like this that sends an input through a different function depending on whether it's even or odd? Any input would be greatly appreciated. 
 A: Hint.  Try working out some of the function values.  For example, if $n=0,1,2,\ldots,10$ then the values of $f(n)$ are
$$2,\,3,\,4,\,7,\,6,\,11,\,8,\,15,\,10,\,19,\,12\ .$$
For $f$ to have an inverse, the values (if the list is extended indefinitely in both directions) must include every integer once each.  Looking at the pattern, do you think this will be true?
Once you are convinced you know the answer you need to give reasons why: you should do one of the following.


*

*If you think there is an integer $y$ which will never appear, name it and explain why $f(n)$ will never equal $y$.

*if you think there is an integer which will occur more than once, name it and give two values of $n$ which produce this integer.

*if you believe neither of the above is true, explain why every integer occurs as a value of $f(n)$ for one and only one value of $n$.


Good luck!
On the side note, some people refer to this kind of thing as a "split" definition.  However I'm not sure if that is a widespread usage.
