A function $f:\mathbb{R}\rightarrow\mathbb{R}$ is locally monotone at point $a$ iff there exists $\epsilon>0$ such that $f|_{]a-\epsilon;a+\epsilon[}$ is monotone ($x\ge y\Rightarrow f(x)\ge f(y)$ for all points $x$, $y$ of $]a-\epsilon;a+\epsilon[$).
Question If a function is locally monotone at all points of real line (or more generally an interval on real line), then it is monotone on the entire real line (or more generally, on this interval)?
If it does not hold for any intervals, does it hold for closed intervals?