How do you construct a function that is continuous over $(0,1)$ whose image is the entire real line?

Hopefully you agree that you want functions with vertical asymptotes at $0$ and $1$, which is why you wanted to try $\frac{1}{x(x-1)}$. The problem with it is that, on the interval $(0,1)$, it goes to $-\infty$ both near $0$ and near $1$ (the easiest calculator-free way to notice this is to note that it is always negative).

How can we fix this problem? By multiplying by a continuous function which is positive near $1$ (so the product still goes to $-\infty$ near $1$) and negative near $0$ (so it goes to $+\infty$ near $0$). One simple function like this is $2x-1$.


I'd like to provide a different flavor of function. For $x \in (0,1)$

$$f(x) = \tan\bigg(\pi x-\frac{\pi}{2}\bigg)$$


EDIT: How we get to above result?

We start with $\tan(x)$, which is continuous over $x \in (-\pi/2, \pi/2)$ whose image is the entire real line.

We want $x$ to be $(0,1)$ instead. So one easy way is we find a linear transformation (thus is continuous) of $x$ to transform $x$ from $(-\pi/2, \pi/2)$ to $(0,1)$.

Notice that if $\pi x \in (-\pi/2, \pi/2)$, then we have $x \in (-1/2, 1/2)$.

And if $(\pi x - \pi/2) \in (-\pi/2, \pi/2)$, then we have $x\in (0,1)$, and that is what we want.


You've come up with a function symmetric about $x=\frac{1}{2}$: it's an "even function" except that it's "even about $x=\frac{1}{2}$" rather than about $x=0$.

Translate left by $\frac{1}{2}$; then you've made a bona fide even function ("even about $x=0$"). Now, to get a function which is "odd about $x=\frac{1}{2}$", just multiply the translated version by $x$ to get a bona fide odd function, and then translate back. That's what you've done (up to a factor of $2$).