Is there a smooth strictly-increasing bijection $\mathbb{R} \to (0, 1)$ that maps $\mathbb{Q}$ onto $\mathbb{Q}\cap(0, 1)$? I noticed that none of the "nice" sigmoid functions I know of sends rationals to rationals.
I set out to find a sigmoid function that maps rationals into rationals.  I did find one, but it is not smooth.  I wonder if such a function exists, and if not, what is the connection between this non-existence and the requirement that it and its inverse map rationals to rationals.
The function
$$
x \mapsto
\begin{cases} 
      \frac{1}{2 (1 - x)} &, \text {if} \ \ x < 0 \\
      \frac{2 x + 1}{2 (1 + x)} &, \text {if} \ \  x \geq 0
\end{cases}
$$
is a strictly increasing bijection from $\mathbb{R}$ onto $(0, 1)$, and it maps $\mathbb{Q}$ into $\mathbb{Q}\cap(0, 1)$.
Furthermore, its inverse
$$
y \mapsto
\begin{cases} 
      \frac{2 y - 1}{2 y} &, \text {if} \ \  0 < y < \frac{1}{2} \\
      \frac{2 y - 1}{2 (1 - y)} &, \text {if} \ \  \frac{1}{2} \leq y < 1
\end{cases}
$$
maps $\mathbb{Q}\cap(0, 1)$ into $\mathbb{Q}$.
Therefore, the restriction of this function to $\mathbb{Q}$ is a monotone bijection from $\mathbb{Q}$ onto $\mathbb{Q}\cap(0, 1)$.
The original function (over $\mathbb{R}$) is not smooth, however: its second derivative does not exist at $x = 0$.
Does there exist a smooth monotone bijection from $\mathbb{R}$ onto $(0, 1)$ whose restriction to $\mathbb{Q}$ maps $\mathbb{Q}$ onto $\mathbb{Q}\cap(0, 1)$?  Is it possible to write down a formula for it?

EDIT: Below is the function one gets if one subtracts $\frac{1}{2}$ from the expressions in the original definition.
$$
x \mapsto
\begin{cases} 
      \frac{x}{2 (1 - x)} &, \text {if} \ \ x < 0 \\
      \frac{x}{2 (1 + x)} &, \text {if} \ \  x \geq 0
\end{cases}
$$
(Informally, this "translates" the graph of the function down by $\frac{1}{2}$, so that the function's value at $0$ is $0$.)
This "translate" of the original function more clearly shows its symmetry.

EDIT2: I realized after the fact that the word "monotone" in the phrase "smooth monotone bijection" is probably redundant.  I cannot envision a smooth bijection on $\mathbb{R}$ that fails to be monotone.  (The sign of the first derivative must remain bounded away from zero if the function is going to be injective.)
 A: First of all, by taking any diffeomorphism   between ${\mathbb R}$ and $(0,1)$ and using it to send ${\mathbb Q}$ to a subset $B\subset {\mathbb R}$, the problem reduces to the following:
Given two countable dense subsets $A, B\subset {\mathbb R}$, find a diffeomorphism $f:  {\mathbb R}\to {\mathbb R}$ such that $f(A)=B$.
Remark. A diffeomorphism between smooth manifolds is smooth map with smooth inverse. In the setting of maps between open intervals in ${\mathbb R}$, diffeomorphisms are bijective functions which are infinitely differentiable and have infinitely differentiable inverses.
This turns out to be always possible. One can even find a real-analytic diffeomorphism with this property. Even more, there exists an entire holomorphic function $h: {\mathbb C}\to {\mathbb C}$ which restricts to a diffeomorphism $f:  {\mathbb R}\to {\mathbb R}$ such that $f(A)=B$.
This result has a long and interesting history. It is usually attributed to
Franklin, P., Analytic transformations of everywhere dense point sets., Transactions A. M. S. 27, 91-100 (1925). ZBL51.0166.01.
See also a more recent proof in
Barth, K. F.; Schneider, W. J., Entire functions mapping countable dense subsets of the reals onto each other monotonically, J. Lond. Math. Soc., II. Ser. 2, 620-626 (1970). ZBL0201.09203.
The same result holds in higher dimensions, see
Morayne, Michał, Measure preserving analytic diffeomorphisms of countable dense sets in ${\mathbb C}^n$ and ${\mathbb{R}}^n$, Colloq. Math. 52, 93-98 (1987). ZBL0627.28012.
and even for Banach manifolds:
Dobrowolski, T., On smooth countable dense homogeneity, Bull. Acad. Pol. Sci., Sér. Sci. Math. Astron. Phys. 24, 627-634 (1976). ZBL0332.58005.
When I have more time I will add a sketch of a proof for existence of $C^\infty$ diffeomorphisms from a smooth manifold $M$ to itself mapping given dense countable subset $A\subset M$ to another given dense countable subset $B\subset M$.
