I'm struggling with a problem that seems very straightforward, so I apologize in advance if the answer is trivial. I'm trying to prove that:
$$f(x) = \begin{cases} x+x^2 & x \in \mathbb{Q} \\ x-x^2 & x \not\in \mathbb{Q} \\ \end{cases} $$ is not monotone on $[0, M)$ for any $M>0$.
My thoughts: Considering only the irrational portion of the function, it is clear that
$$ \sup \{f(x) : x \not\in \mathbb{Q} \} = \frac{1}{4}.$$ So, taking $M > \frac{-1 + \sqrt{2}}{2}$, by the density of the rational's and irrational's, we can find some rational $x_1 \in (\frac{-1 + \sqrt{2}}{2},M)$, some rational $x_2 \in (x_1,M)$, and some irrational $x_3 \in (x_1,x_2)$. Then, since $x_1$ and $x_2$ are rational and greater than $\frac{-1 + \sqrt{2}}{2}$, it follows that
$$\frac{1}{4} < f(x_1) < f(x_2)$$
but $f(x_3) < \frac{1}{4}$, and $x_3 \in (x_1,x_2)$, so $f$ is not monotone on $[0,M)$.
Considering the case when $M \leq \frac{-1 + \sqrt{2}}{2}$ is what is giving me trouble. I understand intuitively that the function "bounces" back and forth between the two parabola's, and $x+x^2 \geq x - x^2$ on $[0,M)$, so clearly it can't be monotone, but I can't seem to prove it formally.
What am I missing here? Do I even need to consider $M$'s case-by-case?