# How do you find the inverse of a composite function

$$f(n) = \begin{cases}-2n,&\text{if }n < 0\\ 2n+1,&\text{if }n\ge 0\end{cases}$$

$$f^{-1}(n) = \begin{cases}-\frac{n}2,&\text{if }n\text{ is even}\\\\ \frac{n-1}2,&\text{if }n\text{ is odd}\end{cases}$$

I would like to know where the $n$ is even and $n$ is odd come from exactly and how to determine the "condition" for similar functions.

-
How is $a$ defined? – Douglas S. Stones Nov 4 '12 at 0:51
@Douglas: Presumably $a$ is an error for $n$; Gladstone? – Brian M. Scott Nov 4 '12 at 1:12
n is supposed to be a since it is the inverse – Gladstone Asder Nov 4 '12 at 1:13
But what you’ve written makes no sense. You can meaningfully say that $f^{-1}(n)=-n/2$ if $n$ is even, or that $f^{-1}(a)=-a/2$ if $a$ is even, or for that matter that $f^{-1}(\xi)=-\xi/2$ if $\xi$ is even, but the symbols have to match. There is no special association of $n$ with the original function and $a$ with the inverse: you could use any name (except $f$) for either one. – Brian M. Scott Nov 4 '12 at 1:16
yeah it's just a mistake – Gladstone Asder Nov 4 '12 at 1:22

Look at the outputs of the function. The odd outputs are the $2n+1$ so to get $n$ back you subtract 1 and then divide by 2: input = (output-1)/2. The even outputs are the $-2n$ so to get back $n$ you divide by $-2$; so input = -(output)/2. Now since inverse function reverses inputs and outputs, you get the formula you displayed. It might help to temporarily change the variable names, and then switch back to $n$ for the input variable to $f^{-1}.$
Make a little table of $f$: $$\matrix{n&-4&-3&-2&-1&0&1&2&3&4\cr f(n)&8&6&4&2&1&3&5&7&9\cr}$$ Now, what do you have to do to get back from $8,6,4,2,1,3,5,7,9$ to $-4,-3,-2,-1,0,1,2,3,4$, from $f(n)$ to $n$? For the even numbers, $8,6,4,2$, you just have to divide by $2$, and change the sign: $x\mapsto-x/2$. For the odd numbers, $1,3,5,7,9$, you subtract $1$ and then divide by $2$: $x\mapsto(x-1)/2$.