Inverse of a piecewise function with even/odd condition

elementary-number-theoryinverse function

Given a function $f:\mathbb{N_0}\rightarrow\mathbb{Z^+}$
and $a,b,c \in \mathbb{Z^+}$ and $b > a$

$$f(n) =
\begin{cases}
c+b\times\frac{n}{2}, & \text{if }n \text{ is even}\\
c+a+b\times\frac{n-1}{2}, & \text{if }n\text{ is odd} \\
\end{cases}$$

How to calculate the inverse of this function?

Best Answer

$$f^{-1}(m) = \begin{cases} 2\times \frac{m-c}{b}&&\text{if}\;m\equiv c\;(\text{mod}\;b)\\ 1+2\times \frac{m-c-a}{b}&&\text{otherwise}\\ \end{cases}$$

Related Question