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

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

When I first saw this problem, I thought $\frac{1}{x(x-1)}$ might work since it is continuous on $(0,1)$, but when I graphed it, I saw that there is a minimum at $(1/2,4)$, so the image is $[4,\infty)$ and not $(-\infty,\infty)$.

Apparently, one answer to this question is:

$$\frac{2x-1}{x(x-1)}$$

But how is one supposed to arrive at this answer without using a graphing calculator?


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.