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?
-
Is it three times only, or $\geq3$ times? – Apr 01 '14 at 23:10
-
$\geq 3$ times is very trivial – Frank Apr 01 '14 at 23:11
-
Exactly three times – Steven Rash Apr 01 '14 at 23:11
-
10If you don't require $f$ to be continuous, no problem. – Daniel Fischer Apr 01 '14 at 23:11
-
1Six answers so far and zero up votes on the question, really? – Git Gud Apr 01 '14 at 23:35
7 Answers
Here's a continuous solution:
$$ f(x) = \begin{cases} 4x-3\lfloor x\rfloor & \text{when $\lfloor x\rfloor$ is even} \\ 3\lfloor x\rfloor + 3 - 2x & \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.
- 234,171
- 12
- 184
- 355
- 291,611
-
@Henning Makholm: Just looking at the graph the first half of the first segment does not seem to attain every height 3 times (visually). That is, values $y<2$. Perhaps you mean the graph extends to negative region too? – P Vanchinathan Apr 02 '14 at 00:25
-
3@PVanchinathan: The function is $\mathbb R\to\mathbb R$; the graph (contributed by Omnomnomnom) shows it only for $x$ between $0$ and $10$, but it is to be understood that it extends indefinitely below and above that interval. – hmakholm left over Monica Apr 02 '14 at 00:30
-
Sorry if I sounded like asking something too obvious. I am curious to know the answer to the same question if we are looking for functions on bounded open interval.Seems like metric or order plays a role. I am not able to see it clearly. – P Vanchinathan Apr 02 '14 at 01:11
-
1@PVanchinathan: From/to an open interval, just compose this function with your favorite homeomorphism between $\mathbb R$ and the open interval -- arctan, erf, tanh, whatever. – hmakholm left over Monica Apr 02 '14 at 09:52
-
1Continuity is ok. As we are composing with a bijection, the number of inverse images remains the same. Nice example. By the way what is erf? – P Vanchinathan Apr 02 '14 at 16:43
-
I am exporting the answer I gave to a closed question.
$$f(x)=2\left\lfloor\frac{x}{3\pi}\right\rfloor-\cos\left(3\pi\left\{\frac{x}{3\pi}\right\}\right)\tag{1}$$ is a differentiable function that attains any real value in exaclty three points, whose graphics is the following one:
$\hskip2in$
If in $(1)$ you replace "$3$" with the positive odd integer $2m+1$, you get a function that attains any real value in exactly $2m+1$ points. You can also take:
$$f(x) = T_{2m+1}\left(x-2\left\lceil\frac{x-1}{2}\right\rceil\right)+2\left\lceil\frac{x-1}{2}\right\rceil,$$
where $T_{2m+1}$ is the $(2m+1)$-th Chebyshev polynomial of the first kind. This is a $C^1(\mathbb{R})$ function, too.
- 361,689
-
I noticed that you posted a comment about it not being a duplicate, but so far I am the only one who has voted to reopen. – Jonas Meyer Aug 12 '14 at 22:28
-
-
@JackD'Aurizio : Could you please see this wolfram plot , I think it shows that the first function is discontinuous ..... http://www4f.wolframalpha.com/Calculate/MSP/MSP296320921ih4d32ai24f000030c9bi25c9ag4hgg?MSPStoreType=image/gif&s=63&w=433.&h=193.&cdf=RangeControl – May 16 '15 at 12:50
Continuity works :
$$ f(x) = \left\{ \begin{array}{ll} 3(x-k)+k & 0\le x-k\le \frac{1}3 \\ −3(x−k)+2+k & \frac{1}{3}\le x-k\le \frac{2}3 \\3(x−k)−2+k &\frac{2}{3}\le x-k\le 1 \end{array} \right. $$
In fact one can prove the following statement : There exists a continuous function that takes all the values of its image exactly $n$ times if and only if $n$ is odd.
-
2Nice general result. The example here generalizes easily to show the "if" direction, but is there a sleek way to show "only if"? – hmakholm left over Monica Apr 01 '14 at 23:43
Yes, in fact there is a very general way to construct functions like this. For example, essentially the same proof works for any $n$ instead of just $3$.
It suffices to note that $\mathbb R$ and $\mathbb R\times \{0,1,2\}$ have the same cardinality. To see this, note that we have an obvious injection $\mathbb R\to \mathbb R\times \{0,1,2\}$, and we can define an injection the other way by $$f(x,y)=\begin{cases} \arctan x\ &\text{if } y = 0\\ \arctan x + \pi &\text{if } y = 1\\ \arctan x + 2\pi &\text{if } y = 2 \end{cases}$$ thus by Bernstein-Schroeder there exists some bijection $g:\mathbb R\to \mathbb R\times \{0,1,2\}$. Now let $h(x)$ be the first component of $g(x)$.
- 61,883
If you can construct a bijection $\varphi:[0,1)\to(0,1)$, then you can construct bijections $f:(-\infty,0)\to(-\infty,\infty),\ g:[0,1)\to(-\infty,\infty)$, and $h:[1,\infty)\to(-\infty,\infty)$, and take their union.
Namely, let $f(x)=\log(-x),\ g(x)=\tan(\pi(\varphi(x)-\frac12)),\ h(x)=g(\frac2{\pi}\arctan(x-1))$.
- 82,298
Here's a continuous, non-piecewise function that does it, and it's very simple too. Consider $$f(x) = \sin(x) + \frac{2x}{3\pi} \text{.}$$
- 2,225
-
1No, $\frac{2}{3\pi}$ is not the right coefficient. Your $f(x)$ has five roots, approximately ${-4.7, -4.3, 0, 4.3, 4.7}$. – hmakholm left over Monica Apr 01 '14 at 23:40
-
You're right. There's gonna be some disgusting math in getting the slope of that $x$ term. I figured I'd just solve $\sin(\frac{3\pi}{2}) + a\frac{3\pi}{2} = 0$ and the slope would be $a$, but it's really not that easy. – Sam Yusim Apr 01 '14 at 23:53
-
See http://math.stackexchange.com/a/1030738/50776: You want the $a$ in $f(x)=\sin x+ax$ to be the unique solution of $\sqrt{1-a^2}=\pi+\cos^{-1}a$ with the usual branch for $\cos^{-1}$, roughly $a\approx0.217234$. This is equivalent to demanding that the unique local minimum of $f(x)$ in the region $[0,2\pi]$ has value $0$. (Also it is more impressive if you say your solution is analytic rather than just continuous, like the other solutions.) – Mario Carneiro Dec 07 '15 at 19:30
- 306
- 3
- 10
-
1Right - couldn't we just take three lines, if we are able to restrict the domain? – The Chaz 2.0 Dec 07 '15 at 18:56
-
Please note that I changed the function, and the domain the entire $\mathbb{R}$ now. – Sobi Dec 07 '15 at 19:29
