# How to find the left inverse of a piece wise defined function

$F(x)=\begin{cases} x-1 & \text{if } x \text{ is even}\\ 2x &\text{if } x \text{ is odd}\end{cases}$

I need to exhibit the left inverse of this function. I know it exists because the function is one-to-one. Now, it's easy for me to switch the $x$'s and $y$'s to get: $$g(x)=\begin{cases} \frac{x}{2} \\ x+1 \end{cases}$$ I know (because the back of the book tells me) that it's $\frac{x}{2}$ if $x$ is even and $x+1$ if $x$ is odd, but I don't know why these evens and odds flipped from the original function. Is there a systematic way to go about solving these inverses that would let me see more clearly what is happening?

So we are given: $$f(x) = \cases { x-1 & x \text{ even} \\ 2x & x \text { odd} \\ }$$

Now, you can see this function is injective. However, we claim it is surjective, and this is the reason why: Let $l$ be an integer.

Suppose $l$ is odd, then $l+1$ is even, right? And from the definition of $f$, we see that $f(l+1) = (l+1)-1 = l$. So, for $l$ odd, we would like the inverse to be $l+1$.

Let $l$ be even, then $\frac{l}{2}$ is well-defined, and $f(\frac l2) = 2 \times \frac l2 = l$.So for $l$ even, we would like the inverse to be $\frac l2$.

Hence, we see that $f$ is surjective. However, the inverse mapping is given by the surjectivity: $$g(l) = \cases{ l+1 & l \text{ odd} \\ \frac l2 & l \text{ even} \\ }$$

Why has the flipping happened? Simple. Both operations (adding $1$, multiplying by $2$) change the odd/even parity of the number (multiplying by $2$ happens only for odd numbers in the definition of $f$, so that all numbers change parity). Any inverse so involved will have to restore this parity (because you get back the same number, so the parity has to be the same, right?). Hence, any odd number will have to go to an even number, and every even number will have to go to an odd number (upon left-composition).

We will verify the inversion.

Suppose $l$ is odd, then we get $f(l) = 2l$, which is now even, so that $g(f(l))= l$.

Suppose $l$ is even, then we get $f(l) = l -1$, which is odd, so that $g(f(l))= l$.

Hence, $g$ is the correct left inverse of $f$.

Notice at first that if $x$ is even, then $x-1$ is odd. And if $x$ is odd, then $2x$ is even. Thus you can some what think of the function as $f(\text{odd})=\text{even}$ and $f(\text{even})=\text{odd}$. Now when applying the inverse, then we get $f^{-1}f(\text{odd}) = \text{odd} = f^{-1}(\text{even})$ and $f^{-1}f(\text{even}) = \text{even} = f^{-1}(\text{odd)}$. That is why it has "flipped". Regarding calculating the inverse you have done correctly, just seemed that you missed the "flip" part.