Proving such a function is always constant

Let $$I \subset R$$ be an interval. Let $$f : I \to R$$ be a continuous function.

Assume that $$I := [a, b]$$. Assume that for all $$c, d \in [a, b]$$ such that $$c < d$$, there exists $$e \in [c,d]$$ such that $$f(e) = f(a)$$ or $$f(e) = f(b)$$. Prove that $$f$$ is a constant.

Consider this statement: For all $$c \in [a,b], f(c) \in \{f(a),f(b)\}$$

I figured that proving this statement would allow me to prove the function to be constant, but I'm unable to do so. Any thoughts?

• Are (or were) you unable to prove the result from your statement, your statement from the given information or both? – PJTraill Nov 22 '18 at 21:53
• The latter actually. @PJTraill – Ahmad Lamaa Nov 23 '18 at 1:43

I assume you want to prove that the function is constant given the statement

$$c \in [a, b] \Rightarrow f(c) \in \{f(a), f(b) \}$$

if that's the case, then we get a continuous function to a discrete space. If the function takes more than one value, the image of our function will be$${f(a), f(b)}$$ which is disconnected. But continous functions preserve connectedness.

• I suppose here $f(c)\in[f(a), f(b)]$. Otherwise the function is discontinuous assuming $f(a)\neq f(b)$. – Yadati Kiran Nov 22 '18 at 15:52
• Yes, assuming $f(a) \neq (fb)$ would mean it is discontinous, which is precisely the contradiction we're using that in fact $f(a)$ must be equal to $f(b)$ and the function is in fact constant. [think about the fact that if in the end both of them were to not be the same, the function would not be constant anyway ] – Aleks J Nov 22 '18 at 15:55

Let $$c$$ in $$(a,b)$$ and let $$\epsilon$$ be a positive real number such that $$[c-\epsilon,c+\epsilon]\subseteq[a,b]$$. Define a sequence of intervals $$(I_n)_{n\in\mathbb{N}}$$ by the formula $$I_n=[c-\frac{\epsilon}{n},c+\frac{\epsilon}{n}]$$. By hypothesis, there exists a sequence of points $$(c_n)_{n\in\mathbb{N}}$$ such that $$c_n\in I_n$$ and $$f(c_n)\in\{f(a),f(b)\}$$. Then $$c_n$$ tends to $$c$$ and, by continuity of $$f$$, we have that $$f(c)\in\{f(a),f(b)\}$$. Thus, by continuity, $$f$$ is constant because it takes values in a discrete space.

• @PJTraill Yes, I corrected it. – Dante Grevino Nov 22 '18 at 23:41

The set $$D:=f^{-1}(f(a))\cup f^{-1}(f(b))$$ is closed by continuity of $$f$$ and dense in $$I$$ by the special property. Clearly $$D$$ does not intersect the open set $$I\setminus D$$. By defnition of dense, this means that $$I\setminus D$$ is empty. Hence $$I=D$$. This makes $$I$$ the union of the two non-empty closed sets $$f^{-1}(f(a))$$, $$f^{-1}(f(b))$$. As $$I$$ is connected, these sets must overlap, which means that $$f(a)=f(b)$$ and ultimately that $$f^{-1}(f(a))=I$$, i.e., $$f$$ is constant.

You need to use intermediate value property of continuous functions.

Suppose $$f(a) =f(b)$$. If $$f$$ is not constant in $$[a, b]$$ then there is some value of $$f$$ which differs from $$f(a) =f(b)$$ and let's suppose this value $$f(c) > f(a)$$ (the case $$f(c) is handled in a similar manner). By continuity there is an interval of type $$[c-\delta, c+\delta]$$ where all values of $$f$$ are greater than $$f(a)$$. And this contradicts the given hypotheses. Thus $$f$$ must be a constant function.

The case when $$f(a) \neq f(b)$$ leads us to a contradiction as shown next. Let's us assume $$f(a) and choose $$k$$ such that $$f(a) . By intermediate value property there is a $$c\in(a, b)$$ for which $$f(c) =k$$. And by continuity there is an interval of type $$[c-\delta, c+\delta]$$ where all values of $$f$$ lie strictly between $$f(a)$$ and $$f(b)$$. This contradiction shows that we must have $$f(a) =f(b)$$ and as shown earlier the function is constant.