# A continuous surjective function from $(0,1]$ onto $[0,1]$

I'm trying to construct a continuous surjection from $(0,1]$ onto $[0,1]$, but I'm not getting anywhere. I don't immediately see a contradiction which falsifies the existence of such a function, so my intuition tells me one exists. I feel like an absolute value function would work, but I'm not sure how to arrive at it in the proper way. Thanks for any help.

• \begin{align} f(x) = \begin{cases} 0 & \text{ for } 0 < x \le \frac 12 \\ 2x-1 & \text { for } \frac 12 \le x \le 1 \end{cases}\end{align} – DanielV Apr 27 '14 at 23:54
• The key is your function cannot be injective and surjective at the same time. You can pick a function which sends a closed subset, say $[1/2,1]$ to $[0,1]$ and then do whatever you want to its value on $(0,1/2]$. As long as its range falls within $[0,1]$, it will continue to work. e.g $\sin\pi x$, $4x(1-x)$... – achille hui Apr 28 '14 at 0:09

Try $f(t) = \sin(1/t)$.

If you want to use your absolute value idea, try making a $V$ shape with the vertex at $(\tfrac12, 0)$, opening upwards to include the points $(0,1)$ and $(1,1)$. (I'll leave the actual function up to you.)

$$4\left(x-\frac{1}{2}\right)^2$$

Some point in the interior of $(0,1]$ will have to map to $0$. I picked $1/2$. Then the rest of the function has to never pass below $0$, so I squared it. Then it needs to actually cover up to and including $1$, so multiply by $4$. The collection of choices here should indicate that there are many such functions.

You could even cover this interval with only the domain $(0,1)$ using a similar method -- minimum at 1/3, maximum at 2/3, cubic...

How about $f(x) = 2 |x-\frac{1}{2}|$

The function $f(x) =\sin^2 2\pi x$ or the variant with cosine should do. It is more than continuous: it is differentiable and has a power series representation.