Produce a bijection from some segment in $\mathbb{Q}$ to $\mathbb{Q}^+$ My abstract algebra text is asking me the following:

Let $A = \{ q \in \mathbb{Q} : a < q < b\}$ for $a,b \in \mathbb{Q}$
Prove $|A| = |\mathbb{Q}^+|$

I realize I have two options:

*

*Explicitly produce a bijection between the two sets

*Show that one exists but don't produce one explicitly

Option 1 is actually pretty simple. Let $$g:A\to\mathbb{Q^+}:q\to\frac{1}{q-a}-\frac{1}{b-a}$$
However I felt like I was doing engineering not pure math when I tried to figure that one out. Is there a less hacky and more logic-bound way to do this?
 A: The restriction to rational numbers is almost a red herring.
The function $x \mapsto \dfrac{1}{x-b} - \dfrac{1}{a-b}$ is a bijection $(a,b) \to (0,+\infty)$.
When $a,b \in \mathbb Q$, this function maps rationals to rationals and vice-versa.
A: Another way to show it: clearly you have an injection $(a,b)\cap {\bf Q} \to {\bf Q}$, and if $N>1/(b-a)$, then $n\mapsto a+1/(N+n)$ gives you an injection ${\bf N}\to (a,b)\cap {\bf Q}$.
Since you have an injection ${\bf Q}\to {\bf N}$, by Cantor-Bernstein-Schroeder, you have a bijection $(a,b)\cap {\bf Q}\to {\bf Q}$ (by virtue of having injections both ways).
A: First $A+|a|\subset \mathbb Q^+$ (the translated of $A$ by $|a|$) so you have $\#A\le\#\mathbb Q^+$ right away.
You need only an injection in the reverse way to conclude.
For $\mathbb R^+$ we usually proceed like this $\begin{cases}
f:[0,+\infty[\to[1,+\infty[ & f(x)=x+1\\
g:[1,+\infty[\to]0,1] & g(x)=1/x\\
h:]0,1]\to]a,b] & h(x)=a+x(b-a)\\
\end{cases}$
But since $a,b$ are rationnal too, these work also for $\mathbb Q^+$.
If we resume the bijection : $y=a+\frac{b-a}{x+1}\iff\frac 1{y-a}=\frac{x+1}{b-a}\iff x=\frac{b-a}{y-a}-1\iff x=\frac{b-y}{y-a}$
Your bijection is slightly different, it is $x=\frac{b-y}{(y-a)(b-a)}$, but the division by $(b-a)$ changes nothing, $[0,+\infty[$ is not affected by an homothetic transform.
You have also probably noticed that $A=]a,b[\cap\mathbb Q$ and not $]a,b]\cap\mathbb Q$, so you are not mapping the $0$ of $\mathbb Q^+$.
But it is not important for the conclusion, since $A$ is infinite, then $A\cup\{b\}$ and $A$ have the same cardinal.

If really you want to construct an explicit bijection between $A$ and $\mathbb Q^+$ you still need to transform $]a,b]$ to $]a,b[$ for instance by defining $U_n=\frac{(2^n-1)a+b}{2^n}$ and $\phi(U_n)=U_{n+1}$ and $\phi(q)=q$ elsewhere.
But exhibiting the explicit bijection is often not needed to show that two sets are equinumerous.
