# How to find all polynomials with rational coefficients s.t $\forall r\notin\mathbb Q :f(r)\notin\mathbb Q$

How to find all polynomials with rational coefficients$f(x)=a_nx^n+\cdots+a_1x+a_0$, $a_i\in \mathbb Q$, such that $$\forall r\in\mathbb R\setminus\mathbb Q,\quad f(r)\in\mathbb R\setminus\mathbb Q.$$ thanks in advance

-
Any suggestion of your own to approach this? –  Did Feb 8 '13 at 20:33
@did:i don't know how begin to solve this kind of question –  Maisam Hedyelloo Feb 8 '13 at 20:39
Guess: $ax+b$ with $a,b\in\Bbb Q,\ a\ne 0$. –  Berci Feb 8 '13 at 20:56
@beci:why ax+b is answer. –  Maisam Hedyelloo Feb 8 '13 at 20:58
@Berci: those are clearly some or all of them because of the closure of the rationals under addition and multiplication. The question is whether that is all of them. –  Ross Millikan Feb 8 '13 at 21:40

The only candidates are those polynomials $f(x)\in\mathbb Q[x]$ that are factored over $\mathbb Q$ as product of first degree polynomials (this is because if $\deg f>1$ and $f$ is irreducible then all of its roots are irrationals.)
(Hint: The polynomial $f(x)+q$, for suitable $q\in\mathbb Q$, is not a product of first degree polynomials)
@Berci: can you see why ax+b can take on the value $\sqrt{2}$? If I had two of these linear polynomials as factors, what would happen? –  Grumpy Parsnip Feb 8 '13 at 21:10
$f(x)=(x+1)(x+1)$ then $f(\sqrt2-1)=2$. –  Asaf Karagila Feb 8 '13 at 21:16