# Creating a bijection from $(a,b)$ to $\mathbb R$ that is visually compelling

I am trying to:

a) find a function that behaves like the function shown, on an open interval - say $(-1/2,1/2)$

b) find some intuition for why/how this function works.

Given this related M.SE question and the use of the circle in the MO post, I am drawn to the tangent function.

1. Sanity check: is $f(x) = -\tan (\pi x)$ from $(-1/2,1/2)$ to the reals, the/a function that fits the picture?

2. Can you provide some visualization that would help me bridge the intuition gap?

In the answer I gave here, I exhibit a bijection $(0,1)\to\Bbb R$. Note that the numerator runs linearly from $-1$ to $1$, while one linear factor in the denominator runs from $0$ to $1$ and the other runs from $1$ to $0$. As we approach the lower bound of the domain, the function tends to $-\infty$; the upper bound, to $+\infty.$ Our choice of factors also makes injectivity and continuity easy to prove.
Something similar can be done for an arbitrary interval $(a,b).$ Put a factor $x-a$ and a factor $b-x$ in the denominator, then make the numerator $2x-(a+b)$. You can scale it however you like.
Your example certainly does the trick, too, and an appropriate transformation will adapt the example to any interval. If you want some help visualizing why your example should work, see the picture in this question, replacing $h$ by $\pi x$. As we allow $x$ to range over $(-\pi/2,\pi/2)$, it becomes readily apparent that the signed length of that long opposite leg takes on every real value, and that to each signed length corresponds a unique $x$ in that range. Thus, $\tan(\pi x)$ is a bijection, so since $x\mapsto -x$ is a bijection, then your example works.