# Continuous extensions reals and to p-adic numbers

Assume $f\colon \mathbb Q\to \mathbb Q$ is a function which admits continuous extensions

• $f_0\colon\mathbb R\to \mathbb R$ and
• $f_p\colon \mathbb Q_p\to \mathbb Q_p$ for each prime $p$.

Is it true that $f$ is a polynomial?

I guess the answer is no, but I do not see a counterexample.

-
Given two countable dense subsets $A,B\subset \mathbb{R}$, there is a continuous homeomorphism $f:\mathbb{R}\rightarrow\mathbb{R}$ such that $f(A)=B$. You can construct this function by just carefully choosing, one-by-one, the images of points of A (and the preimages of points of B). I believe this problem is exactly the same: just enumerate the rationals $q_{0},q_{1},...$, then choose $f(q_{i})$ so that it is near where you would expect it in $\mathbb{R}$, and $\mathbb{Q_{p})$ for the first $i$ primes $p$. –  David Cohen Aug 26 '11 at 19:18

Specifically, enumerate the non-zero rationals $\{r_1,r_2, \ldots\}$ in some way. Now consider the function: $$f(x) = \sum_{n=1}^{\infty} c_n x^{n^2} \prod_{i=1}^{n} (x - r_i).$$ If $c_n \in \mathbf{Q}$, then this is a well defined function from rationals to rationals. On the other hand, $f(x)$ converges to an analytic function in $\mathbf{Q}_v$ if and only if the coefficients of this power series converge to zero fast enough. Since the coefficients of the power series in the range $k = n^2$ to $k < (n+1)^2$ are simply the cofficients of $c_n x^{n^2} \prod_{i=1}^{n} (x - r_i)$, this can be ensured by forcing these coefficients to be very highly divisible by the first $n$ primes, and small in the archimedean sense (by including a very very large prime in the denominator).