39
$\begingroup$

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?

$\endgroup$
5
  • $\begingroup$ Is it three times only, or $\geq3$ times? $\endgroup$
    – user122283
    Apr 1 '14 at 23:10
  • $\begingroup$ $\geq 3$ times is very trivial $\endgroup$
    – Frank
    Apr 1 '14 at 23:11
  • $\begingroup$ Exactly three times $\endgroup$ Apr 1 '14 at 23:11
  • 10
    $\begingroup$ If you don't require $f$ to be continuous, no problem. $\endgroup$ Apr 1 '14 at 23:11
  • 1
    $\begingroup$ Six answers so far and zero up votes on the question, really? $\endgroup$
    – Git Gud
    Apr 1 '14 at 23:35
36
$\begingroup$

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.

$f(x)$ from $x = 0$ to $10$

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.

$\endgroup$
6
  • $\begingroup$ @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? $\endgroup$ Apr 2 '14 at 0:25
  • 3
    $\begingroup$ @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. $\endgroup$ Apr 2 '14 at 0:30
  • $\begingroup$ 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. $\endgroup$ Apr 2 '14 at 1:11
  • 1
    $\begingroup$ @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. $\endgroup$ Apr 2 '14 at 9:52
  • $\begingroup$ Continuity 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? $\endgroup$ Apr 2 '14 at 16:43
15
$\begingroup$

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$enter image description here

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.

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$ Aug 12 '14 at 22:28
  • $\begingroup$ I'm gonna vote too. $\endgroup$ Aug 12 '14 at 22:40
  • $\begingroup$ @JackD'Aurizio : Could you please see this wolfram plot , I think it shows that the first function is discontinuous ..... www4f.wolframalpha.com/Calculate/MSP/… $\endgroup$
    – user228168
    May 16 '15 at 12:50
11
$\begingroup$

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.

$\endgroup$
1
  • 2
    $\begingroup$ Nice general result. The example here generalizes easily to show the "if" direction, but is there a sleek way to show "only if"? $\endgroup$ Apr 1 '14 at 23:43
4
$\begingroup$

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)$.

$\endgroup$
1
  • $\begingroup$ @AymanHourieh I do indeed. $\endgroup$ Apr 1 '14 at 23:26
2
$\begingroup$

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))$.

$\endgroup$
0
$\begingroup$

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{.}$$

$\endgroup$
3
  • 1
    $\begingroup$ No, $\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\}$. $\endgroup$ Apr 1 '14 at 23:40
  • $\begingroup$ 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. $\endgroup$ Apr 1 '14 at 23:53
  • $\begingroup$ See 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.) $\endgroup$ Dec 7 '15 at 19:30
-1
$\begingroup$

$\text{cotan}(\frac{3\pi}{1+e^{-x}})$ will do. Here is the plot of the function:

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Right - couldn't we just take three lines, if we are able to restrict the domain? $\endgroup$ Dec 7 '15 at 18:56
  • $\begingroup$ Please note that I changed the function, and the domain the entire $\mathbb{R}$ now. $\endgroup$
    – Sobi
    Dec 7 '15 at 19:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.