Function $f: \mathbb{R} \to \mathbb{R}$ that takes each value in $\mathbb{R}$ three times Does there exist a function $f: \mathbb{R} \to \mathbb{R}$ that takes each value in $\mathbb{R}$ three times? If not, how could I prove that such a function does not exist?
Here's a continuous solution:

$$ f(x) = \begin{cases} 4x-3\lfloor x\rfloor &amp; \text{when $\lfloor x\rfloor$ is even} \\
3\lfloor x\rfloor + 3 - 2x &amp; \text{when $\lfloor x \rfloor$ is odd} \end{cases} $$

This takes on the values $0,4,2,6,4,8,6,10,8,\ldots$ at integer $x$ and interpolates linearly between them.



Any even number $2m$ is hit at $f(2m)$ (a local minimum), $f(2m-\frac32)$ (the middle of an increasing line segment), and $f(2m-3)$ (a local maximum). All other numbers are hit by a point in an increasing line segment, then a decreasing one, and finally another increasing one.



A smoother function with the same overall shape would be $g(x)=ax+\sin x$, except the coefficient $a$ has to be just right in order to get the local maxima and minima to coincide, and I'm too lazy to figure out what it should be.
$\text{cotan}(\frac{3\pi}{1+e^{-x}})$ will do. Here is the plot of the function: