For polynomial $f$, does $f$(rational) = rational$^2$ always imply that $f(x) = g(x)^2$?
If $f(x)$ is a polynomial with rational coefficients such that for every rational number $r$, $f(r)$ is the square of a rational number, can we conclude that $f(x) = g(x)^2$ for some other polynomial $g(x)$ with rational coefficients?
I proved the quadratic case in my answer to this question, and am guessing that the general case is true, but don't know how to proceed.
Does this extend to polynomials in several variables? What about in different fields of fractions? Note: this is not true for complex numbers, since every complex value is the square of a complex number, but linear polynomials are not perfect squares
It seems like the proper formulation of this question is that if $f(x_1, x_2, \ldots x_n)$ is a polynomial with integer coefficients such that every integer specialization of $x_1, x_2, \ldots, x_n$ is a perfect $p$th power, then $f$ is a perfect $p$th power polynomial.
A proof is available here, which further shows that it only needs to hold for some $|x_i| < C$ (though it's a humongous $C$). Theorem 4 answers the question above and is similar to that presented by Franklin. The multi-variable case is dealt with via induction.
First, we don't need to consider rational coefficients. We can clear denominators multiplying by a square integer. For the polynomial with integer coefficients it is enough to know that it is a square for integer input.
Now you need to prove that infinitely many primes are going to be divisors of the output of any non-constant polynomial $h$ in the integers. Assume that $p_1,\ldots, p_r$ are the only primes that divide every value $h(n)=a_nx^n+\cdots+a_1x+a_0$. Then take $h(a_0p_1\cdots p_r)=a_0\left(a_0^{n-1}a_n(p_1\cdots p_r)^n+\cdots+1\right)$. A la Euclid's proof the last factor should be divisible by a new prime (we probably need to take $r$ large to avoid that that last factor is $1$).
If $a_0=0$ then $h(x)=xg(x)$, so just put $x=p$ any prime you want to divide $h(p)$.
Write $f=g^2h$ with $h$ squarefree. Take a prime $p$ that doesn't divide the resultant $R(h,h')$ but such that divides $h(n)$ for some $n$. Such a $p$ and $n$ exists because of what we proved above. Since $f(n)$ is a square $p^2|h(n)$. Now $h(n+p)$ is also divisible by $p$ and therefore also divisible by $p^2$. But $h(n+p)=h(n)+ph'(n)$ mod $p^2$. This implies $p$ divides $h'(n)$ and therefore divides $R(h,h')$. Contradiction. Therefore $h$ is constant. Finally this constant $h$ must be a square since $f$ is always giving you square values.
This is a baby application of Hilbert's irreducibility Theorem.