TITLE: Smooth functions for which $f(x)$ is rational if and only if $x$ is rational
QUESTION [27 upvotes]: 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.

REPLY [7 votes]: Sergei Ivanov has given a positive answer for the existence of such functions on MO:
https://mathoverflow.net/questions/48910/smooth-functions-for-which-fx-is-rational-if-and-only-if-x-is-rational.