Function oscillating between $[-1,1]$ around $0$.

I was looking for examples of functions $f:\mathbb{R}\to\mathbb{R}$ such that for any $a>0$ we have that $[-1,1]\subseteq f\left([-a,a]\right)$

The two examples I could think of were $\sin(1/x)$ and $\cos(1/x)$. However, I was wondering if there are other, interesting examples of such a function? Perhaps ones not involving trigonometric functions? I'd be grateful for some suggestions.

• Should $f$ be continuous in any way? – Asaf Karagila Mar 3 '13 at 9:36
• Nope, it doesn't have to be. – Johnny Westerling Mar 3 '13 at 9:39
• Then what about the function taking the value -2 at every rational point and 2 at every irrational point. – Fixed Point Mar 3 '13 at 9:59
• But for that function, $f([-a,a])$ is the set $\{{-2,2\}}$, which does not include the interval $[-1,1]$. – Gerry Myerson Mar 3 '13 at 11:53

If $-1\lt x\lt1$, and $x\ne0$, let the decimal expansion of $x$ be $x=\pm.000\dots0d_1d_2d_3\dots$ with $d_1\ne0$. Then let $f(x)=\pm.d_1d_2d_3\dots$. For $x=0$ and for $|x|\ge1$ the definition of $f$ is arbitrary. Then for every $a\gt0$ and for every $y$ in $[-1,1]$ there is an $x$ with $-a\lt x\lt a$ and $f(x)=y$.
Indeed f takes on the value of every real number on any closed interval $[a,b]$ where $b > a$. (Wikipedia, Conway base 13 function)
So in particular for every $a\in\Bbb R$ we have $[-1,1]\subseteq\Bbb R\subseteq f([-a,a])$. Seems much more than just an oscillation around zero.