# Smooth functions for which $f(x)$ is rational if and only if $x$ is rational

A friend of mine introduced me to the following question: Does there exist a smooth function $f: \mathbb{R} \to \mathbb{R}$, ($f \in C^\infty$), such that $f$ maps rationals to rationals and irrationals to irrationals and is nonlinear?

I posed this question earlier in math.stackexchange.com (link to the question) where it received considerable interest. There hasn't been an answer so far, but one commenter suggested to bring it here.

Related results

• The friend who told me the problem has been able to prove that no polynomial satisfies the required conditions.

• If we required just that $f \in C^1$, then we can cut and paste the function $x \mapsto \frac{1}{x}$ to provide a nonlinear example: $$f(x) = \begin{cases}\frac{1}{x-1} + 1, & x \le 0 \\\\ \frac{1}{x+1} - 1, & x \ge 0\end{cases}$$

There are such functions. Moreover any diffeomorphism $f_0:\mathbb R\to\mathbb R$ can be approximated by such $f$. For the sake of simplicity I assume that $f_0'\ge 2$ everywhere.

Enumerate the rationals: $\mathbb Q=\{r_1,r_2,\dots\}$, and construct a sequence $f_0,f_1,f_2,\dots$ of self-diffeomorphisms of $\mathbb R$ satisfying the following:

• $f_{2k-1}(r_k)\in\mathbb Q$, and $f_n(r_k)$ is the same for all $n\ge 2k-1$

• $f_{2k}^{-1}(r_k)\in\mathbb Q$, and $f_n^{-1}(r_k)$ is the same for all $n\ge 2k$.

• The first $k$ derivatives of the difference $f_k-f_{k-1}$ are bounded by $2^{-k}$ everywhere on $\mathbb R$.

Such a sequence has a limit $f$ in $C^\infty$, and this limit is a diffeomorphism satisfying $f(\mathbb Q)\subset\mathbb Q$ and $f^{-1}(\mathbb Q)\subset\mathbb Q$.

The sequence $\{f_i\}$ can be constructed by induction. To construct $f_{2k-1}$ from $g:=f_{2k-2}$, consider $g(r_k)$. If it is rational, let $f_{2k-1}=g$. If not, let $I$ be an open interval containing $r_k$ and not containing any of the points $r_i$ and $g^{-1}(r_i)$ for $i\le k-1$. (Note that $r_k$ is different from these points due to the fact that $g(r_k)\notin\mathbb Q$). Then define $f_{2k-1}=g+\varepsilon\cdot h$ where $h$ is your favorite smooth function with support contained in $I$ and such that $h(r_k)\ne 0$, $\varepsilon$ is so small that the above derivative estimates hold and is chosen so that $f_{2k-1}(r_k)\in\mathbb Q$. To construct $f_{2k}$ from $f_{2k-1}$, do a similar perturbation near the pre-image of $r_k$, assuming it is not yet rational.

In the answer to this close question I remarked how to make an entire, non polynomial function bijecting two assigned countable dense sets $A$ and $B$.

Also, you can make a non-analytic $C^\infty$ self-diffeo of $\mathbb{R}$ that bijects $A$ and $B$ with similar procedure. Say a $C^\infty$ diffeo, which is not the identity map, but with a tangency of infinite order to the identity map at $0$.

• @Pietro: I don't understand how you can run your procedure described as is in that other question here. You say: "inductively add only odd degree polynomials $p_n$, that vanish on the (finitely many) already settled points, and do not destroy the invertibility on $\mathbb{R}$, but if you start with $p_1(x) = qx$ for some rational $q$, then the "already settled points" is already in fact all the points that you want... – Willie Wong Dec 10 '10 at 13:41
• that's no problem, "already settled" just means the first (approximatively) $n/2$ of $A$ plus their images, and the first $n/2$ of $B$ plus their pre-images. – Pietro Majer Dec 10 '10 at 14:03
• Ah, so you are implicitly using an enumeration of the two sets. Okay. – Willie Wong Dec 10 '10 at 14:04
• yes, it was explicit in the lines above. Sorry, I though it was clear enough. – Pietro Majer Dec 10 '10 at 18:10

How's this for explicit? Take $$f(x) = \sum_{n=1}^\infty 2^{-\lfloor n/x \rfloor}$$ for $0 < x \leq 1$, and then extend this by $f(x) = \lfloor x \rfloor + f(x-\lfloor x \rfloor)$.

If $x$ is rational, then $f(x)$ is easily seen to have a repeating binary expansion, and so is rational. If $x$ is irrational, then $f(x)$ is easily seen to not have a repeating expansion, so is irrational. That $f$ is continuous is also easy, and so is the fact that $f$ is strictly increasing. It also has derivative 0 almost everywhere.

• I don't think it is smooth.... – Willie Wong Dec 10 '10 at 14:06
• Kevin, that's really pretty! Can you say a word about smoothness? The "almost everywhere" bit bothers me somewhat. – Alex B. Dec 10 '10 at 14:07
• @Alex Bartel: if a $C^1$ function has almost everywhere 0 derivative, it must be constant. That tells you about its smoothness. – Willie Wong Dec 10 '10 at 14:17
• I saw the continuous requirement, but missed the request for additional smoothity. – Kevin O'Bryant Dec 10 '10 at 15:13
• Smoothity... that's a great word. :-) – Willie Wong Dec 10 '10 at 16:24

It is true that given any two dense subsets $A,B\subset(0,1)$, there is an absolutely monotone function $[0,1]\rightarrow[0,1]$ which carries $A$ to $B$. I don't know the exact proof of this, but the idea is very simple: you enumerate the elements of $A$ and $B$, then take the first element of $A$, and associate it with an appropriate element of $B$, then the first element of $B$ and associate it with an appropriate element of $A$, then associate the second element of $A$ to an appropriate element of $B$, etc.

I am fairly certain that some variation on this should work for your problem.

• The question asks for a smooth function – Francesco Polizzi Dec 10 '10 at 13:20
• Also, the problem is not to prove that such functions exist, it's to find out if there are nonlinear examples. – Thierry Zell Dec 10 '10 at 14:09