Suppose that the function $p(x)$ is defined on an open subset $U$ of $\mathbb{R}$ by a power series with real coefficients. Suppose, further, that $p$ maps rationals to rationals. Must $p$ be defined on $U$ by a rational function? 



Is a real power series that maps rationals to rationals defined by a rational function?
No. In fact, $p(x)$ can be a complex analytic function with rational coefficients that takes any algebraic number $\alpha$ in an element of $\mathbb{Q}(\alpha)$. 
(And everywhere analytic functions are not rational unless they are polynomials).


The algebraic numbers are countable, so one can find a countable sequence of polynomials $q\_1(x), q\_2(x), \ldots \in \mathbb{Q}[x]$ 
such that every algebraic number is a root of $q\_n(x)$ for some $n$. Suppose that
the degree of $q\_i(x)$ is $a\_i$, and choose integers $b\_i$ such that
$$b\_{n+1} > b\_{n} + a\_1 + a\_2 + \ldots + a\_n.$$


Then consider the formal power series:


$$p(x) = \sum\_{n=0}^{\infty} c\_n x^{b\_n} \left( \prod\_{i=0}^{n} q\_i(x) \right),$$


By the construction of $b\_n$, the coefficient of $x^k$ for $k = b\_n$ to
$b\_{n+1} -1$ in $p(x)$ is the coefficient of $x^k$ in 
$c\_n x^{b\_n} \prod\_{i=1}^{n} q\_i(x)$. Hence, choosing the $c\_n$ to be appropriately
small rational numbers, one can ensure that the coefficients of $p(x)$ decrease sufficiently rapidly and thus guarantee that $p(x)$ is analytic.


On the other hand, clearly $p(\alpha) \in \mathbb{Q}[\alpha]$ for every (algebraic)
$\alpha$, because then the sum above will be a finite sum.


With a slight modification one can even guarantee that the same property holds for all derivatives of $p(x)$.


I learnt this fun argument from the always entertaining Alf van der Poorten (who sadly died recently).


