Inverse of a piecewise function with even/odd condition

173 Views Asked by At

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?

1

There are 1 best solutions below

1
On 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}$$