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

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.

Solutions Collecting From Web of "A continuous surjective function from $(0,1]$ onto $$"

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.