# $f: \mathbb{R} \to \mathbb{R}$ that takes each value in $\mathbb{R}$ twice

Does there exist a continuous function $f: \mathbb{R} \to \mathbb{R}$ that takes each value in $\mathbb{R}$ exactly two times?

• I think by the Intermediate Value Theorem this isn't possible, but proof seems a little confusing. – Seth Mar 28 '14 at 22:01
• @Seth You're right. Pick two points with $f(a)=f(b)$; there's a (not necessarily unique) maximum of $f$ in $[a,b]$ (assume the max isn't at a,b for convenience, otherwise look at $-f$); if this max is achieved once in this interval then it must be achieved elsewhere, use IVT to show that points between $f(a)$ and $f(max)$ are achieved at least 3 times. If it's achieved twice in the interval do the same thing, but noting first that there's a min between $f(max_1)$ and $f(max_2)$. – user98602 Mar 28 '14 at 22:05
• Yes, that sounds good. I was trying to write up a proof (it's obvious in my head but hard to write down on paper) but I think you explained it pretty well. – Seth Mar 28 '14 at 22:07
• Actually I just realized that if you view the map as a path (so the domain is time) then it is even more intuitively clear. – Seth Mar 28 '14 at 22:29
• Any idea where the problem comes from? A colleague mentioned it to me a couple of months ago. – Andrés E. Caicedo Mar 29 '14 at 1:56

Suppose $f(a)=f(b)=0$. Then on each of $(-\infty,a)$, $(a,b)$, $(b,\infty)$ the function $f$ is either positive or negative by the intermediate value theorem. By continuity $f$ has either a max on $[a,b]$ which is strictly positive or a min which is strictly negative. WLOG say it has a max which is positive. The left and right intervals must have opposite signs or $f$ can't be surjective. So say WLOG the left side is positive. Then some (very small) positive value is achieved three times, once on the left interval and twice in the middle interval.

• Would this solution be considered rigorous enough for an exam? It feels like it relies on geometric intuition too much. – Akash Gaur Nov 7 '18 at 4:54

Suppose for sake of contradiction that such function exists. Let $a,b$ be two real numbers such that $f(a)=f(b)$ and $a<b$. Then either $f(x)>f(a)$ for all $x\in (a,b)$ or $f(x)<f(a)$ for all $x\in (a,b)$. If were not such the case then we have $c,d\in (a,b)$ such that $f(c)\le f(a)\le f(d)$, taking the value of $f(a)$ a third time. We may assume that $f(x)<f(a)$ for all $x\in (a,b)$. Now we choose some $x_0\in (a,b)$ (whatever works), thus $f$ takes all the values between $f(a)=f(b)$ and $f(x_0)$ twice in $[a,x_0]$ and $[x_0,b]$.

For $x<a$ or $x>b$ we cannot have $f(x)<f(a)$ because this would imply that $f$ takes these values yet a third time (if were the case of some $x$ such that $f(x)<f(a)$ and assume by concreteness $x<a$, so all the values between $y=\max\{f(x),f(x_0)\}$ and $f(a)=f(b)$ are taking by $f$ three times, since $f(x)\le y<f(a)$, $f(x_0)\le y < f(a)$ and $f(x_0)\le y < f(b)$ in $[x,a]$,$[a,x_0]$ and $[x_0,b]$). Hence for $x<a$ and $x>b$ we must have $f(x)> f(a)$.

Thus for what we have seen $f$ is bounded below by the minimum on $[a,b]$ and then $f$ does not take each $x\in\mathbb{R}$, in particular does not take any value less than the minimum value of $f$ in $[a,b]$, a contradiction.

$\mathbb{R}$ cannot have any nontrivial connected covering space, including a $k$-sheeted covering map from itself for any finite $k > 1$, because it is simply connected.

• Hmm this is a good proof, but don't you need invariance of domain to prove that such a map would be a two sheeted cover? – Seth Mar 28 '14 at 22:27
• I think you just prove that there is a locally continuous pair of pre-images of every point. Maybe invariance of domain could play a role if you wanted to make the same argument for $R^n$, but then again it might not. Not having though through the general case I stated it only for $R$. – zyx Mar 28 '14 at 22:33

If possible let, f be such a continuous function in $\Bbb R$ which attains every value exactly twice.
Let $f(x_1)=f(x_2)=b$, with $x_1 \neq x_2$.
Then $f(x)\neq b$, for $x_1 \neq x_2$.
Then either $f(x)\gt b$ or $f(x)\lt b \forall x\in (x_1,x_2)$.
In case , when f(x)\gt b: there is f(x_0)=max. {f(x):x\in (x_1,x_2)}. Now we claim that, $f$ attains its maximum exactly once in $(x_1,x_2)$, otherwise $f$ will attain each value more than two times. Let, $f$ attains its maximum exactly once at $c\in (x_1,x_2)$. Again since $f$ attains its value exactly two times, thus there exists $x_3$ ,outside of the interval $[x_1,x_2]$, S.t. $f(x_3)=f(c)=d$ (,say) $\gt b$. Then by IVP , we can conclude that f attains every value between $b$ and $d$ at least three times, CONTRADICTION. Same argument can be applicable for $f(x)\lt b$. Thus there doesn't exists any such continuous function.

• $f$ might not be differentiable. – user99914 May 8 '17 at 8:56
• I actually use intermediate value property. If a function f be continuous on a closed and bounded interval ...... – gobinda chandra May 8 '17 at 9:01
• Even a function be not continuous, but may assume IVP – gobinda chandra May 8 '17 at 9:06
• I see, now you need to fix your answer as you invoke mean value theorem at some point (but not really using it). – user99914 May 8 '17 at 9:13
• Ok. I actually use f'(x) to show that f attains its maximum. But you may noy use it. Here the next ans below... – gobinda chandra May 8 '17 at 9:16