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

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.