Is there a function from $(0, 1)$ to $\mathbb{R}$ that is surjective but not injective? I know there are injections [e.g. $\tan(x)$] and bijections [e.g. the classic $\tan(\pi (x-\frac{1}{2}))$] from $(0, 1)$ to $\mathbb{R}$, but I had been stuck after I tried to construct a function from $(0, 1)$ to $\mathbb{R}$ that is only surjective but not injective. So I wonder if there is any example. Thanks in advance!
 A: If $f$ is a bijection $(0,1)\to\mathbb R$, then consider
$$ g(x) = \begin{cases}f(2x) & x\in(0,1/2), \\  0& x\in [1/2,1).\end{cases}$$
A: If you already have a bijection $f: (0, 1) \to \Bbb R$ (such as $f(x) = \tan(\pi (x-\frac{1}{2}))$) then you can compose it with any function $g: \Bbb R \to \Bbb R$ which is surjective but not injective. Then $g \circ f: (0, 1) \to \Bbb R$ has the desired properties.
A possible choice for $g$ is $g(x) = x^3 - x$, or any other odd-degree polynomial which is not strictly increasing.
A: Sure,  it's not mysticism.  With infinite sets of equal cardinality you can always tweak things.
Let $\phi$ be a bijection from $(0,1)\to \mathbb R$. You give the classic of $\phi(x) = \tan(\pi(x-\frac 12))$.  That only will do nicely.
Then $\phi': (0,\frac 12) \to \mathbb R$ via $\phi'(x) = \phi(2x)$ is a bijection.
And $\overline{\phi}:(\frac 12,1)\to \mathbb R$ via $\overline{\phi}(x) =\phi'(x-\frac 12) = \phi(2(x-\frac 12))$ is a bijection.
And $\gamma:(0,1)\to \mathbb R$ via $\begin{cases} \phi'(x) & x < \frac 12\\ \overline{\phi}(x) & x > \frac 12\\e^{\sqrt{27} + \pi} - \frac 2{517}& x = \frac 12\end{cases}$.
(and if $w =
$\gamma$ is surjective because for any $w \in\mathbb R$ then we an $x=\phi^{-1}(w)\in (0,1)$ so that $\phi(x) = w$.  For example if  $\phi: x\mapsto \tan(\pi(x-\frac 12))$ then $x=\phi^{-1}(w) = \frac {\arctan (w)}{\pi} + \frac 12$ will be that $\phi(x) = w$.
And so $\gamma (\frac 12 \phi^{-1}(w))=\phi'(\frac 12 \phi^{-1}(w))=\phi(2\cdot \frac 12 \phi^{-1}(w))=\phi(\phi^{-1}(w)) = w $ and $\gamma(\frac 12 \phi^{-1}(w) +\frac 12) = \overline{phi}(\frac 12 \phi^{-1}(w) +\frac 12) = \phi(2(\frac 12 \phi^{-1}(w) +\frac 12-\frac 12))=\phi(\phi^{-1}(w)) = w$.
So $\gamma$ is surejective.  But $\frac 12 \phi^{-1}(w)\ne \frac 12 \phi^{-1}(w) +\frac 12$ so $\gamma$ is not injective.
(and if $w = e^{\sqrt{27} + \pi} - \frac 2{517}$ then we have $\frac 12, \frac 12(\frac {\arctan ( e^{\sqrt{27} + \pi} - \frac 2{517})}{\pi} + \frac 12),$ and $12(\frac {\arctan ( e^{\sqrt{27} + \pi} - \frac 2{517})}{\pi} + \frac 12)$ all mapping to $w$.)
