Let $f:[a,b] \rightarrow R$ be continuous such that $f(a)=f(b)$. Let $f:[a,b] \rightarrow R$ be continuous such that $f(a)=f(b)$. Show that for each $\epsilon>0$, there exist distinct $x,y \in [a,b]$ such that $|x-y|<\epsilon$ and $f(x)=f(y)$.
I can not solve this problem. Please if anybody help me, I will be very pleased.
 A: One may suppose that $f$ is not constant. Let $c\in (a,b)$ such that $f$ has an extremum at $c$, ($c$ exists by the fact that $f(a)=f(b)$). Let $\varepsilon>0$, small, and suppose that $f$ is injective on $\displaystyle J_{\varepsilon}=(c-\frac{\varepsilon}{2}, c+\frac{\varepsilon}{2})\subset ]a,b[$. Then as $f$ is continuous, $f$ is strictly monotonic on $J_{\varepsilon}$, et this contradict the fact that $f$ has an extremum at $c$. This show the assertion.  
A: Assume without loss of generality that $f$ is not constant. Let $c$ be a extremum point of $f$ in $(a,b)$ (why this point exists?), for example, let's assume it is a maximum. Take $\epsilon>0$ small and consider the numbers $$m_1=\min_{\Large{x\in [c-\frac{\epsilon}2,c]}} f(x),\ m_2=\min_{\Large{x\in[c,c+\frac{\epsilon}2]}} f(x).$$
If $m_1=f(c)$ then $f(x)=f(c)$ for all $x\in [c-\frac{\epsilon}2,c]$ therefore, just take $x,y\in [c-\frac{\epsilon}2,c]$ with $x\neq y$
If $m_2=f(c)$ then $f(x)=f(c)$ for all $x\in [c,c+\frac{\epsilon}2]$ therefore, just take $x,y\in [c,c+\frac{\epsilon}2]$ with $x\neq y$
Thus, assume that $m_1<f(c)$ and $m_2<f(c)$. Let $m=\max\{m_1,m_2\}$ and note that for any number $d\in ]m,f(c)[$, there is $x\in ]c-\frac{\epsilon}2,c[$, $y\in ]c,c+\frac{\epsilon}2[$, such that $f(x)=f(y)=d$, and $x\neq y$, $|x-y|<\epsilon$.
