Construct a function $f:[0,1] \to [0,1]$ that takes every value in $[0,1]$ an infinite number of times. I have a homework problem that I'm completely stumped on: Construct a function $f:[0,1] \to [0,1]$ that takes every value in $[0,1]$ an infinite number of times. I spent the better part of 2 hours on this problem, so I need some help. I started with a piece-wise function, just to get the every value an infinite number of times part, and played with it to make it continuous, but I made no progress. It's a very hard problem for me.
 A: Hint: Draw a line connecting the points $(0,0)$ with $(1/2, 1)$. Draw a line connecting $(1/2,1)$ with $(3/4,0)$. Connect to $(7/8, 1)$.
A: You want a function that oscillates "violently". Not sure if you have seen such wildly oscillating functions using $\sin$. If you have not seen it, the question is unfair as only a certified genius can come up with such examples without any prior knowledge. That said, here is very broad hint...
$$
f(x) = \sin(g(x))
$$
where you want $g(x)$ to grow to infinity in the interval. Then $f$ will have infinitely many oscillations. Now pick your favorite $g(x)$ that has a singularity in $[0,1]$
A: Here is an easy answer if you've seen how to construct a space-filling curve: just take a continuous mapping of the closed unit interval $[0,1]$ onto the closed unit square $[0,1]\times[0,1]$, and follow it with a projection of the square onto its horizontal side. In other words, if $x=f(t),y=g(t),0\le t\le1$ is a parametric representation of a continuous curve which fills the unit square, then $f:[0,1]\to[0,1]$ is a continuous function which takes every value in $[0,1]$ an uncountable number of times.
