Prove $f(x)$ is constant. Suppose $ f: \mathbb{R} \mapsto \mathbb{R}$ be continous. For any interval $[a,b]$, there exists $x_0\in (a,b)$ such that either $f(x_0)=\max\limits_{a\le x \le b} f(x)$ or $f(x_0)=\min\limits_{a\le x \le b} f(x)$. Prove $f(x)$ is constant.
We may consider apply Reductio ad Absurdum. Suppose $f(x)$ is not constant, then there exist $\alpha<\beta$ such that $f(\alpha)\neq f(\beta).$ But how to reduce the contradiction?
 A: Let $ I = [a, b] $ be any closed interval and assume, without loss of generality, that $ f $ attains its maximum value $ M $ in the interior; the case where it attains its minimum value instead is similar. Suppose $ f(a) < f(b) $ without loss of generality, I'll obtain a contradiction from this assumption.
Since $ f $ is continuous, $ [a, b] \cap f^{-1}(\{ M \}) $ is a closed and bounded set, therefore it has minimum and maximum values $ x_{\textrm{min}}, \, x_{\textrm{max}} $. If $ x_{\textrm{min}} = a $ then $ f(a) = M $ and this contradicts $ f(a) < f(b) $, so we can assume $ x_{\textrm{min}} > a $.
Now, since $ x_{\textrm{min}} $ is the minimum value for which $ f $ attains its maximum value $ M $, it can't attain the value $ M $ anywhere in the interval $ (a, x_{\textrm{min}}) $. Therefore it must instead attain its minimum value $ m $ on the interval $ [a, x_{\textrm{min}}] $ somewhere in the interior. Similar to the above, take the maximum value such that $ f $ attains its minimum $ m $ there, call it $ y_{\textrm{max}} $. If $ y_{\textrm{max}} = x_{\textrm{min}} $ then $ m = M $ and therefore $ f(a) = m = M $ once more, which yields the same contradiction as above with $ f(a) < f(b) $. Therefore we must have $ y_{\textrm{max}} < x_{\textrm{min}} $, in which case $ f $ attains neither its maximum nor its minimum on $ [y_{\textrm{max}}, x_{\textrm{min}}] $ in the interior, yielding a contradiction.
We conclude that $ f(a) < f(b) $ is impossible, and we can similarly show that $ f(a) > f(b) $ is impossible, so we must have $ f(a) = f(b) $. Since $ a, b $ were arbitrary, it follows that $ f $ is constant.
A: Suppose that there exist $a$ and $b$  such that $f(a) \neq f(b)$. Let $y:=\max \{x \in [a,b] | f(x) =f(a)\}$ and $z:=\min \{x\in [y,b]| f(x)=f(b)\}$, then $y<z$.
Note that if $x \in (y,z)$ then $f(x) \neq f(a) \neq f(b)$ .
But $f$ attains an extremal value in $(y,z)$, WLOG assume that its the minimum. Then there exist a $d$ such that  $f(d)\leq\min \{f(a),f(b)\}<\max \{f(a),f(b)\}$ so by the IVT there exist a $c\in (y,z)$ such that $f(c)=\min \{f(a),f(b)\}$ a contradiction.
A: Suppose $f$ is continuous and not constant, then by the conditions given, for each $(a,b)$ there exists a non empty set $\mathfrak M_{(a,b)}=\{M_1,M_2, ... \}$ such that $a<M_1<M_2<...<b$, with $$f(M_k)=M=\max_{x\in [a,b]} f(x)$$
In other words, $f$ attains it's maximum inside the set $(a,b)$ exactly $\#\mathfrak M_{(a,b)}$ times (which may be infinite) and at each point inside that set.
We then observe that $x\in[a,M_1)\implies f(x)<f(M_1)$, since we assumed that $M_1$ was the smallest point inside the set where $f$ attains its maximum in the set. This directly implies that $$\max_{x\in[a,M_1]}f(x)=f(M_1)$$ but $M_1\notin(a,M_1)$, which violates the condition that it's maximum is attained in the interior of the set.
Arguing similarly for the minimum, we may declare $\mathfrak m_{(a,b)}=(m_1, m_2,...)$ the set of minimums on $(a,b)$ with $a<m_1<m_2<...<b$ and $$f(m_k)=m=\min_{x\in[a,b]} f(x)$$
Again: $$x\in[a,m_1)\implies f(x)>f(m_1)\implies \min_{x\in[a,m_1]}f(x)=f(m_1)$$
with $m_1\notin (a,m_1)$ violating the same condition.
However, we have that $m_1<M_1$ or $m_1>M_1$. Suppose that $m_1<M_1$, then it is not guaranteed that $f(y)=\max_{x\in[a,m_1]}f(x)\implies y\notin(a,m_1)$, which would satisfy the condition on that range. We can argue similarly for $m_1>M_1$.
Thusly, we must combine the two: noticing in the case of $m_1<M_1$ that $$x\in(m_1, M_1)\implies m_1<f(x)<M_1\implies\min_{x\in[m_1,M_1]}f(x)=f(m_1), \max_{x\in[m_1,M_1]} f(x)=f(M_1)$$ neither of which are in the set $(m_1,M_1)$. and arguing  similarly for $m_1>M_1$
A: Suppose $f(\alpha)<f(\beta)$ for contradiction.
Let $A:=\{x:f(x)\le f(\alpha), x\le \beta\}$. It is non-empty since $\alpha\in A$ and bounded above by $\beta$, so it has a supremum $y=\sup A$. By continuity, $f(y)\le f(\alpha)$.
Similarly consider $B:=\{x:f(x)\ge f(\beta), y\le x\}$. It is also non-empty and bounded below by $y$, so it has an infimum $z=\inf B$. Again, $f(z)\ge f(\beta)$
Now consider the interval $[y,z]$ which has a point $w$ that is either a max or min inside the interval $(y,z)$. This would be a contradiction as $w\in A$ or $w\in B$. Hence $y=z$. But this then contradicts that $f$ is continuous.
A: Not sure of my approach, this is very equivalent to @Ege Erdil answer. Let us consider the interval $[\alpha, \alpha + \epsilon]$ and suppose $f$ non constant, in the way $f(\alpha) < f(\alpha + \epsilon)$.
According to the given condition, $\exists x_0 \in (\alpha, \alpha + \epsilon) : f(x_0) = \max_{x \in [\alpha, \alpha + \epsilon]} f(x) \vee f(x_0) = \min_{x \in [\alpha, \alpha + \epsilon]} f(x)$.
As $f$ is continuous, we can take the limit of this relation where $\epsilon \to 0$:
$$\lim_{\epsilon \to 0} \max_{x \in [\alpha, \alpha + \epsilon]} f(x) = f(\alpha + \epsilon)$$
$$\lim_{\epsilon \to 0} \min_{x \in [\alpha, \alpha + \epsilon]} f(x) = f(\alpha)$$
We see that $\alpha + \epsilon \not\in (\alpha, \alpha + \epsilon)$, and $\alpha \not\in (\alpha, \alpha + \epsilon)$, hence contradicting the given condition. The same reasoning can be done for $f(\alpha) > f(\alpha + \epsilon)$. It comes that $f$ must be constant.
