# 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?

He has been able to prove that such a polynomial (with degree at least 2) doesn't exist.

The problem has been asked before at least at http://www.artofproblemsolving.com.

• That link would be more helpful if it took us straight to the question. Commented Dec 7, 2010 at 13:19
• As a side note: If we required just $f \in C^1$, then looking at the function $f$ defined by $f(x) = \frac{1}{x-1} + 1$ for $x \le 0$ and $f(x) = \frac{1}{x+1} - 1$ for $x \ge 0$ provides an example. There is also an example for the case where we drop the requirement that irrationals are mapped to irrationals. Commented Dec 7, 2010 at 16:50
• It seems kind of hard to get a grip on these things. That class of functions isn't stable under addition, multiplication (though it is under multiplication by elements of $\mathbb Q$), exponentation or limits, ruling out most of the standard machinery of analysis. It is stable under iteration, though, so maybe dynamics could help? Commented Dec 7, 2010 at 18:01
• What a nice question! If it turns out no one here can answer it you might eventually want to try mathoverflow too. Commented Dec 8, 2010 at 16:35
• @Noah: I did that now, mathoverflow.net/questions/48910/…. Commented Dec 10, 2010 at 12:06