1. Another function challenge question

Challenge question:

Find a function $f(x)$ with domain $[0,1]$ that takes on the values in its range a finite even number of times. Or show that no such function exists.

2. Originally Posted by Sampras
Challenge question:

Find a function $f(x)$ with domain $[0,1]$ that takes on the values in its range a finite even number of times. Or show that no such function exists.
The intervals [0,1/2] and (1/2,1] both have the cardinality of the continuum, so there exists a bijective function $x\mapsto g(x)$ from (1/2,1] to [0,1/2]. Define $f(x) = x$ if $0\leqslant x \leqslant 1/2$, and $f(x) = g(x)$ if $1/2. Then f takes each value in its range exactly twice.

On the other hand, if you wanted f to be a continuous function, then I guess the answer would be different.

3. Originally Posted by Opalg
The intervals [0,1/2] and (1/2,1] both have the cardinality of the continuum, so there exists a bijective function $x\mapsto g(x)$ from (1/2,1] to [0,1/2]. Define $f(x) = x$ if $0\leqslant x \leqslant 1/2$, and $f(x) = g(x)$ if $1/2. Then f takes each value in its range exactly twice.

On the other hand, if you wanted f to be a continuous function, then I guess the answer would be different.
A continuous function.

4. This is not a complete solution but it narrows down the possibilities:

The Extreme Value Theorem says that the absolute maximum and the absolute minimum of a continuous function on an interval occur either at the endpoints of the interval or at the critical points. Let us call this set of points Q. If all the points in Q have distinct y-values, then one of them is the absolute maximum of the function and this value is attained in the given interval only at that point.

If the cardinality of Q is odd, it follows by the pigeonhole principle that some y-value in Q occurs an odd number of times. [If a y-value occurs an odd number of times in Q and the cardinality of Q is odd, then it also occurs an odd number of times in the function on the given interval.]

Therefore, if the function satisfies the properties that all y-values occur an even number of times on the given interval, the cardinality of Q is even.

I need help proving the bracketed statement, but I am convinced it is true.