TITLE: What are some examples of a doubling function $f:\mathbb{R} \to \mathbb{R}$
QUESTION [6 upvotes]: A function $f : X \to Y$ is a “doubling” function if for every
$y \in Y$ , there are exactly two distinct values $x_1,x_2 \in X$ such that $f(x_1) = f(x_2) = y$.
I am satisfied with the answer to my previous question - $f:\mathbb{R} \setminus \{0\} \to \mathbb{R}$ given by $f(x) = \log|x|$ has this property. But we want the domain and codomain to be $\mathbb{R}$. Hence choose some bijection $g:\mathbb{R} \to \mathbb{R} \setminus \{0\}$ and $ f \circ g:\mathbb{R} \to \mathbb{R}$ should do the trick.
However, this function cannot be defined when x is 0. What kind of function then would be 'doubling' for all real numbers?

REPLY [2 votes]: [note: this is very similar to my answer on the other post]
$$f(x)=x-\frac{\lceil x \rceil }{2}$$
and
$$g(x)=x-\frac{\lfloor x \rfloor }{2}$$
should do the trick.
Edit: the first posting of this question was deleted, so I've migrated my old answer over here.

$\phantom{fillerfillerfillerfillerfiller}$
\begin{align}f(x)=\begin{cases}
  \vdots \\
  x & 0<x\leq 1\\
  x-1/2 & 1<x \leq 2\\
  x-1 & 2<x \leq 3 \\
  x-3/2 & 3<x \leq 4\\
\vdots 
\end{cases}
\end{align}
Generally, we take $f(x)=x-\frac{z}{2}$ when $z< x \leq z+1$, where $z \in \mathbb{Z}$.