# Give an example of a continuous function $f:R\rightarrow R$ which attains each of its values exactly three times. [duplicate]

• Give an example of a continuous function $f:R\rightarrow R$ which attains each of its values exactly three times.

Ed.: answered by the duplicate above

• Does there exist a continuous function $f:R\rightarrow R$ which attains each of its values exactly two times?

## marked as duplicate by Thomas Andrews, Andrew D. Hwang, Adam Hughes, Gabriel Romon, Martin SleziakAug 12 '14 at 18:28

• math.stackexchange.com/questions/730692/… – Seth Aug 12 '14 at 17:52
• I think this is a duplicate. – Git Gud Aug 12 '14 at 17:52
• math.stackexchange.com/questions/735842/… – Seth Aug 12 '14 at 17:53
• It is not an exact duplicate, because the other question do not ask to exhibit a function with the property that any value in the image is took three times. – Jack D'Aurizio Aug 12 '14 at 18:21
• Neither it is a duplicate of the other question, it is just both of them. It would have some sense to merge the three questions into this topic. – Jack D'Aurizio Aug 12 '14 at 22:41

$$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 $C^1$-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.

You cannot have a continuous function $g$ that takes any value in $g(\mathbb{R})$ exactly twice. Such function cannot be monotonic, hence must have a point $x_0$ of local maximum/minimum and another point $x_1\neq x_0$ for which $g(x_1)=g(x_0)$. Then, by continuity, there exists a constant $G$ sufficiently close to $g(x_0)$ but different from $g(x_0)$ such that there are two points $y_1,y_2$ in a neighbourhood of $x_0$ (because $x_0$ is a maximum/minimum), and at least one point $y_3$ in a neighbourhood of $x_1$ such that $$g(y_1)=g(y_2)=g(y_3)=G,$$ contradiction.

• Very nice example :-) – idm Aug 12 '14 at 18:23
• Are you sure you want those curly brackets in the argument of the cosine? – Miguel Angel Alarcon Bustos Oct 22 '17 at 16:51
• @MiguelAngelAlarconBustos: I am pretty sure. Why do they bother you? – Jack D'Aurizio Oct 22 '17 at 17:17
• Well, because it would be just $\cos(x)$ so they don't play a very important role there (unless they mean something different from what I am thinking). And I was trying to plot it on matplotlib and it wasn't continuous – Miguel Angel Alarcon Bustos Oct 22 '17 at 17:29