# Function with two preimages per y

I am searching for a function f: R -> R which has exactly two preimages for every y. I was thinking about stuff like x^2 but this function doesn’t have preimages for y<0 and furthermore, there is just one preimages for y=0.

So I came to the idea, that a function like that cannot be continuous (might be an interesting thing to prove that).

Does anyone have a nice example for a function f like that?

• For the continuous case see, e.g., this – lulu Jan 20 '18 at 21:33

As noted in the comments, this $f$ will not be continuous.
Define $f:\mathbb{R}\to\mathbb{R}$ by $f(x)=x-k$ if $2k-1<x\leq 2k+1$ for some $k\in\mathbb{Z}$.
Construct a bijection $f_1 : (-\infty, 0) \to \mathbb R$ and a bijection $f_2 : [0, \infty) \to \mathbb R$. Define $$f(x)=\left\{ \begin{array}{cc} f_1(x) & \mbox{ if } x < 0 \\ f_2(x)& \mbox{ if } x \geq 0 \\ \end{array} \right.$$