# Can a continuous real function take each value exactly 3 times? [duplicate]

Let $f: \mathbb{R} \to D \subseteq \mathbb{R}$ be a continuous function. Is there a function $f$ that satisfies the following property? $\forall y \in D$, there are exactly 3 $x_1,x_2,x_3 \in \mathbb{R}$ such that $f(x_1) = f(x_2) = f(x_3) = y$.

## marked as duplicate by Git Gud, Jonas Meyer, user139000, Dirk, HakimNov 20 '14 at 13:58

• How about $f:\Bbb R \to \{0\}$ defined by $f(x) = 0$? – Regret Nov 20 '14 at 10:04
• Oops, I meant there are exactly 3 points $x_1,x_2,x_3$. – user194082 Nov 20 '14 at 10:05
• Maybe useful: math.stackexchange.com/questions/525694/…. – Martín-Blas Pérez Pinilla Nov 20 '14 at 10:08
• @Martín-BlasPérezPinilla , I tried a similar approach. Consider the intervals $[x_1,x_2],[x_2,x_3]$. Then we have a maximum in each interval, $M_1,M_2$. Let $M = max\{M_1,M_2\}$. I can show that $M$ must appear at least twice in $(-\infty,x_1) \cup (x_1,\infty)$, but I can't figure out any kind of contradiction. – user194082 Nov 20 '14 at 10:32

Answer is yes. Consider the piece-wise affine function described in this (poor) chart:

• PS: was too lazy to give a parametrization but I'd still be curious to see one – Alexandre Halm Nov 20 '14 at 10:41

Let $\phi\colon[0,1]\to\mathbb{R}$ be defined as $\phi(x)=1-3\,|x-1/3|$ and let $$f(x)=\sum_{k\in\mathbb{Z}}(\phi(x-k)-k)\,\chi_{[k,k+1]}(x).$$ where $\chi_A$ is the characteristic function of the set $A$.

• this is interesting. Does this approach generalize for $n\geq 3$ if we define $\phi(x,n) = 1 - n|x - \frac{1}{n}|$? – user194082 Nov 20 '14 at 10:56
• @user194082: intuitively, for every even $n$ there will be no such $f$ (not checked, but likely to be similar to case $n=2$) – Alexandre Halm Nov 20 '14 at 11:54
• The $3$ is just for convenience. It has nothing to do with the fact that $f(x)=y$ has exactly $3$ solutions. – Julián Aguirre Nov 20 '14 at 13:24

There are many examples, e.g

• as a piecewise cubic curve $$x + 16\{x\}^3 - 24\{x\}^2 + 8\{x\} = x + \frac12\bigg[T_{n}(2\{x\}-1)-(2\{x\}-1)\bigg]$$ where $T_n(x)$ is the $n^{th}$ Chebyshev polynomials of first kind. Please note that if one replace $n$ by other odd positive integers, we will obtain a function whose pre-images come in group of $n$ instead of group of $3$.

• or even as a smooth curve $$(\cos\theta) x - \sin x \quad\text{ with }\quad \cos\theta \sim 0.21723362821122$$ and $\theta$ is a root of $\;\tan\theta = \pi + \theta\;$ near $1.35$.

With $D=\mathbb R$, let $$f(x)=\begin{cases}2x-3\lfloor x\rfloor &\text{if \lfloor x\rfloor is even}\\3-4x+3\lfloor x\rfloor&\text{if \lfloor x\rfloor is odd}\end{cases}$$