Definition:
Let $f: [0, 1] \rightarrow \mathbb{R}$ be a function. Say $f$ is Totally-Nonmonotonic iff for any $a, b$ in [$0, 1$], $f$ is NOT monotonic on [$a, b$].
Question:
Let $f: [0, 1] \rightarrow \mathbb{R}$ (both of which are equipped with the topology generated by the usual distance) be a continuous function and let $\epsilon$ be a real positive real number. Prove that there exists a continuous totally-nonmonotonic function $g: [0, 1] \rightarrow \mathbb{R}$ such that |$f(t) - g(t)$| $\leq \epsilon$ for every $t \in [0, 1]$.
I am tempted to apply Stone-Weirstrass Theorem here but then realize that although the set of all totally-nonmonotonic continuous functions does separate points in $C[X, \mathbb{R}]$, however, it is not a subalgebra because, assuming $h$ is a totally-nonmonotonic continuous function, both $h$ and $-h$ are in the set but $h + (-h)$ is not in the set. I think the purpose here is to prove that the set of all totally-nonmonotonic continuous function is dense in $C[X, \mathbb{R}]$. Could you anybody provide me some hints if you have any ideas?
Any responses will be appreciated.
Build a continuous and nowhere monotonic $h$ on $[0,1]$ with $h(0)=0$,$h(1)=1$ and $|h|\le1$ as done here. For fixed $\epsilon>0$ there is some $n$ s.t. $|x-y|<1/n$ implies $|f(x)-f(y)|<\epsilon$. Let $I_k=[\frac kn,\frac{k+1}n]$, $k=0,...,n-1$ partition $[0,1]$ and set $h_k(x)=(f(\frac{k+1}n)-f(\frac kn))h(nx-k)+f(\frac kn)$. Observe $g(x)=\sum_k \chi_{I_k}h_k(x)$ is continuous and nowhere monotonic. Now any $x\in [0,1]$ belongs to some $I_k$ so $|f(x)-g(x)|\le|f(x)-f(k/n)|+|f(k/n)-g(x)|\le 2\epsilon$.