If the square of a rational polynomial has integer coefficients does it have integer coefficients as well? 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.
 A: Yes, the original polynomial has integer coefficients.
Take any prime $p$ in a denominator of a term.   Let the coefficients be  $$a_i=p^{r_i}b_i$$  where the $b_i$ contain no factors of $p$, in either their numerator or denominator.
The values $r_i$ may be positive or negative, but by assumption at least one is negative.  Let $$-R=\min_i r_i\\k=\min\{i|r_i=-R\}$$
Now calculate $(f(x))^2$.  In the sum of terms that contributes to $x^{2k}$, the only term with $p^{2R}$ in the denominator is $(a_k)^2$.
No factor has larger than $p^{R}$ .in the denominator , and terms to the right of $x^k$  have smaller powers of $p$.
So, over a common denominator, that is the only term not a multiple of $p$.  So the full coefficient of $x^{2k}$ will not have a multiple of $p$ in the numerator.  It won't cancel, and that coefficient won't be an integer.
A: 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.
