TITLE: If the square of a rational polynomial has integer coefficients does it have integer coefficients as well?
QUESTION [5 upvotes]: Given a polynomial $f \in \mathbb{Q}[x]$ such that $f^2 \in \mathbb{Z}[x]$, is $f \in \mathbb{Z}[x]$?
In words, if the square of a rational polynomial has integer coefficients does it have integer coefficients as well?
I doubt this is true, but it appears to be true for $f$ with degree less than 3 (by inspection of the coefficients). For $\text{deg}f \ge 3$ I can't tell based on looking at coefficients, and I haven't found a counterexample yet.

REPLY [3 votes]: That’s just a reformulation of arguments made in the comments and the previous answer, but it might be clearer: there exists a minimal positive integer $N$ such that $f_1:=Nf$ has integer coefficients. Then $f_1^2=N^2f^2$ has coefficients divisible by $N^2$.
So if $p$ is a prime dividing $N$ and $g_1$ is the reduction mod $p$ of $f_1$, then $g_1^2=0$. Thus $g_1=0$, and therefore $f_1/p=N/p \times f$ has integer coefficients, contradicting the minimality of $N$. So $N=1$ and we are done.