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?
Let $I$ be an order-convex subset of $\Bbb R$, and suppose that $f:I\to\Bbb R$ is locally monotone. For $a,b\in I$ write $a\sim b$ iff either $a\le b$ and $f$ is monotone on $[a,b]$, or $b<a$ and $f$ is monotone on $[b,a]$; $\sim$ is an equivalence relation on $I$. $I$ is connected, and it follows from the local monotonicity of $f$ that each $\sim$-equivalence class is open, so $I$ must be a $\sim$-class, and $f$ is monotone on $I$.