# Can a surjective continuous function from the reals to the reals assume each value an even number of times?

Suppose $f: \mathbb{R} \rightarrow \mathbb{R}$ is continuous and onto. Is it possible for $f$ to assume each of its values an even number of times?

To clarify, some values might be taken 2 times, some 4, some 6, etc., but always an even (and therefore finite) number. I don't require that there be a value that is assumed any particular number of times. For example, the function might never take on any value exactly twice.

Here is a closely related question with an excellent answer.

• From the previous question you link, wouldn't composing the corresponding function with a continuous bijection between $\mathbb{R}_+$ and $\mathbb{R}$ do the trick? Sep 18, 2015 at 14:28
• Since the range of the function in the answer is $[0, \infty)$, not $(0, \infty)$, that won't work. Sep 18, 2015 at 14:30
• @NoahSchweber By $\mathbb{R}_+$, I do mean $[0,\infty)$. (I usually use $\mathbb{R}_+^\ast$ for $(0,\infty)$). (But i can't recall if such continuous bijection exists. [After checking -- no, there is none, so this indeed won't work.] Sep 18, 2015 at 14:31
• @ClementC. There is no continuous bijection between $[0, \infty)$ and $\mathbb{R}$. Suppose there was some, call it $f$ - then let $a=f(0)$, $b=a+1$, and $c=a-1$. Since $f$ is surjective, we must have $f(b')=b$ and $f(c')=c$ for some $b', c'\in (0,\infty)$ (0 is excluded since we know $f(0)=a$). Moreover, since $b\not=c$ we know $b'\not=c'$. But then by the intermediate value theorem, there is some $a'$ between $b'$ and $c'$ such that $f(a')=a$. But $0$ is not between $b'$ and $c'$, so $a'\not=0$. So $f$ is not injective. Sep 18, 2015 at 14:36
• @NoahSchweber Yes, I realized it after writing my comment... Sep 18, 2015 at 14:38

This is impossible. Suppose that $f:\mathbb{R}\to\mathbb{R}$ is such that the preimage of every point contains an even number of points. There are only countably many points in $\mathbb{R}$ that are either local minima or local maxima of $f$ (since for each one, we can choose an interval with rational endpoints on which it is the unique global maximum/minimum). It follows that there exists some $a\in \mathbb{R}$ such that none of the preimages $x_1<x_2<\dots<x_n$ of $a$ are local minima or local maxima. That is, $f(x)-a$ changes sign at each $x_i$. Since $n$ must be even, it follows that $f(x)-a$ has the same sign on all of $\mathbb{R}\setminus [x_1,x_n]$. Since $f$ is bounded on $[x_1,x_n]$, it follows that $f$ is either bounded below or bounded above (depending on which sign it has on $\mathbb{R}\setminus [x_1,x_n]$).

(This argument is borrowed from this nice partial answer to a near-duplicate of your previous question.)

• Very nice. Thanks again. Sep 18, 2015 at 17:45