Show that the function $f(x)=2\lfloor x\rfloor-x$ defined from $f:\mathbb{R}\to\mathbb{R}$ is onto $f:\mathbb{R}\to\mathbb{R}$ is defined by $f(x)=2\lfloor x\rfloor-x$ where $\lfloor \cdot \rfloor$ is greatest integer function.
How to show that it is an onto function without the help of graph?
It is given it is invertible.
And what would be $f^{-1}$?
 A: If the fractional part of $x$ is denoted by $\{x\},$
then $f^{-1}(x) = \lfloor x \rfloor + (1 - \{x\}).$
A: Let $g(y)=2\lceil y\rceil-y,$ where $\lceil\cdot\rceil$ is the ceiling function.
Then, since $0\leq \lceil y\rceil -y<1$ we have:
$$g(y)=\lceil y\rceil +(\lceil y\rceil-y)$$
So
$$\lfloor g(y)\rfloor =\lceil y\rceil$$
So $$\begin{align}f(g(y))&=2\lfloor g(y)\rfloor -g(y)\\
&=2\lceil y\rceil -(2\lceil y\rceil-y)\\
&=y
\end{align}$$
A similar argument gives $g(f(x))=x.$

This can be seen as related to two bijections $\mathbb Z\times[0,1)\to\mathbb R$:
$$q_+(n,z)=n+z, q_-(n,z)=n-z.$$
Then $$q_+^{-1}(x)=(\lfloor x\rfloor,x-\lfloor x\rfloor)\\
q_-^{-1}(y)=(\lceil y\rceil, \lceil y\rceil-y)$$
Then your $f=q_-\circ q_+^{-1}$ and thus $f^{-1}=q_+\circ q_-^{-1}.$
A: To prove any function is onto you simply show that for any $w \in $ the co-domain that $f(x) = w$ will have a solution.
SO if $w\in \mathbb R$ we have to show that there exist an $x$ so the $2[x] - x= w$.
Now bear in mind $x = [x] + \{x\}$ (where $[x]$ is defined to be an integer so that $n \le x < n+1$ and $\{x\}$ is defined to be $x-[x]$).
So $2[x]-\{x\} = 2[x] - ([x]+\{x\}) = [x]-\{x\}$
So we need to solve $[x]-\{x\} = w$.
Well $w = [w] + \{w\}$ so we need $[x] - \{x\} = [w] + \{w\}$ and $[x]-[w]=\{x\} + \{w\}$.
Now $[x] -[w]$ is an integer.  And $0\le \{x\} +\{w\} < 2$. so we must have $\{x\} + \{w\} = 0$ or $1$.
For $\{x\} +\{w\} =0$ we must have both $\{x\}$ and $\{w\}$ equal to $0$.
For $\{x\} + \{w\} = 1$ well each term is strictly less than $1$ we must have both $\{x\}$ and $\{w\}$ not equal to $0$.
So case 1:  $\{w\} = 0$ and $w = [w] + \{w\}$ is an integer.  The we must have $[x]-[w] = 0$ so $[x] = [w]$ and $\{x\} = 0$ so $x = [x] = [w] = w$.
So if $w \in \mathbb Z$ then $x= w$ and $f(w) = 2[w] -  w= 2w-w = w$.
Case 2:  $\{w\} \ne 0$ so $[w] < w < [w]+1$ and $\{w\} + \{x\} = 1$ so $\{x\} = 1 - \{w\}$.
Ane $[x] -[w] = 1$ so $[x] = [w] + 1$ and so $x = [x] + \{x\} = [w] + 1 + (1-\{w\})= [w] + 2-\{w\}$.
That does it.  If $w\not \in \mathbb Z$ then
$f([w] + 2-\{w\}) = 2[([w]+1)+(1-\{w\})] - ([w]+2-\{w\}) =$
$2([w]+1) - [w] - 2 + \{w\} = [w] + \{w\} = w$.
Either case there will always be a real $x$ so that $f(x) = w$
.....
If we use the notation that $\lceil x \rceil$ is the unique integer $m$ so that $m-1 < x \le m$, and if we use the notation $\}x\{$ = \lceil x\rceil -x$ then
if $w\not \in \mathbb Z$, $\lceil w \rceil =\lfloor w \rfloor + 1$ and $\}w\{ = 1-\{w\}$ so we can write $[w] + 2-\{w\} = [w]+1 + (1-\{w\} =\lceil w\rceil -\}w\{$.
And if $w \in \mathbb Z$ then $\lceil w\rceil =\lfloor w \rfloor = w$ and $\}w\{ = \{w\} = 0$.
And $w =\lceil w\rceil -\}w\{$
So in either case  $x = \lceil w\rceil -\}w\{$ will be a solution to $f(x) = w$
