Inverse of a function 2 What is the inverse of the function $f(x)=x+3[2x]+2[3x]$?
The function is one by one and has an inverse.
 A: Given
$$  f(x)=x+3\lfloor2x\rfloor+2\lfloor3x\rfloor $$
Since
$$ x=\left(x-\lfloor x \rfloor\right)+ \lfloor x \rfloor$$
we have
\begin{eqnarray}
f(x)&=&x-\lfloor x \rfloor + \lfloor x \rfloor\\
&&+3\lfloor2\left(x-\lfloor x \rfloor+ \lfloor x \rfloor\right)\rfloor+2\lfloor3\left(x-\lfloor x \rfloor+ \lfloor x \rfloor\right)\rfloor\\
&=&x-\lfloor x \rfloor+3\lfloor2\left(x-\lfloor x \rfloor\right)\rfloor+2\lfloor3\left(x-\lfloor x \rfloor\right)\rfloor\\
&&+\lfloor x \rfloor+6\lfloor x \rfloor+6\lfloor x \rfloor\\
&=&f\left(x-\lfloor x \rfloor\right)+13\lfloor x \rfloor
\end{eqnarray}
On the interval $[0,1)$, the function $f$ can be defined piecewise as follows:
\begin{equation}
f(x)=\begin{cases}
x & 0\le x<\frac{1}{3}\\x+2&\frac{1}{3}\le x<\frac{1}{2}\\x+5&\frac{1}{2}\le x<\frac{2}{3}\\x+7&\frac{2}{3}\le x<1
\end{cases}
\end{equation}
Combining with equation (1) we get
\begin{eqnarray}
f(x)&=&f\left(x-\lfloor x \rfloor\right)+13\lfloor x \rfloor\\
&=&+13\lfloor x \rfloor+\begin{cases}
x-\lfloor x \rfloor & 0\le x-\lfloor x \rfloor<\frac{1}{3}\\x-\lfloor x \rfloor+2&\frac{1}{3}\le x-\lfloor x \rfloor<\frac{1}{2}\\x-\lfloor x \rfloor+5&\frac{1}{2}\le x-\lfloor x \rfloor<\frac{2}{3}\\x-\lfloor x \rfloor+7&\frac{2}{3}\le x-\lfloor x \rfloor<1\end{cases}\\
&=&\begin{cases}
x+12\lfloor x \rfloor & 0\le x-\lfloor x \rfloor<\frac{1}{3}\\x+12\lfloor x \rfloor+2&\frac{1}{3}\le x-\lfloor x \rfloor<\frac{1}{2}\\x+12\lfloor x \rfloor+5&\frac{1}{2}\le x-\lfloor x \rfloor<\frac{2}{3}\\x+12\lfloor x \rfloor+7&\frac{2}{3}\le x-\lfloor x \rfloor<1\end{cases}\\
\end{eqnarray}
So for $n\in\mathbb{Z}$ we may define $f$ on the interval $[n,n+1)$ as follows:
\begin{equation}
f(x)=
\begin{cases}
x+12n &  n+0\le x<n+\frac{1}{3}\\
x+12n+2&n+\frac{1}{3}\le x<n+\frac{1}{2}\\
x+12n+5&n+\frac{1}{2}\le x<n+\frac{2}{3}\\
x+12n+7&n+\frac{2}{3}\le x<n+1\end{cases}
\end{equation}
So the graph of the function consists of collection of straight line segments of slope 1. Each segment can be easily inverted. 
Let us invert the first segment:
\begin{eqnarray}
y=x+12n&\text{ for }&n\le x<n+\frac{1}{3}\\
x=y+12n&\text{ for }&n\le y<n+\frac{1}{3}\\
y=x-12n&\text{ for }&n\le y<n+\frac{1}{3}\\
y=x-12n&\text{ for }&13n\le x<13n+\frac{1}{3}\\
\end{eqnarray}
Applying the same process to each of the four parts give the inverse function.
For each integer $n$ and for each $x$ in the specified interval, $f^{-1}(x)$ is defined as follows:
\begin{equation}
f^{-1}(x)=\begin{cases}
x-12n&\text{ for }13n+0\le x<13n+\frac{1}{3}\\
x-12n-2&\text{ for }13n+\frac{7}{3}\le x<13n+\frac{5}{2}\\
x-12n-5&\text{ for }13n+\frac{11}{2}\le x<13n+\frac{17}{3}\\
x-12n-7&\text{ for }13n+\frac{23}{3}\le x<13n+8
\end{cases}
\end{equation}
Note that the domain of the inverse is a collection of disjoint intervals.
