Is continuous $f$ constant if every point of $\mathbb{R}$ is local minimum of $f$? Suppose $f:\mathbb{R} \rightarrow \mathbb{R}$ is continuous. Is $f$ constant if every point of $\mathbb{R}$ is local minimum of $f$?
What metric spaces we can use instead of $\mathbb{R}$?
I guess we have same result for $f:\mathbb{R}^n \rightarrow \mathbb{R}$.

This holds for $f:X\to\mathbb R$ if $X$ is a connected space.  For each $x\in X$, $f^{-1}([f(x),\infty))$ is closed by continuity, and open by the condition on local minima.  This set is nonempty because it contains $x$, hence it equals $X$ by connectedness.   Thus for all $y\in X$, $f(y)\geq f(x)$.  Because $x$ and $y$ were arbitrary, this implies that $f$ is constant.
See also Continuous function with local maxima everywhere but no global maxima.
