A low-degree polynomial $g_{a,b}(x)$ which has a zero $x\in\mathbb N$ for any square numbers $a,b$? Question : Letting $a,b$ be natural numbers, does there exist a $n$-th degree integer-coefficients polynomial $g_{a,b}(x)$ which satisfies the following three conditions?


*

*Condition 1: $1\le n\le3.$

*Condtion 2: If $a,b$ are square numbers, then there exists a natural number $x$ such that $g_{a,b}(x)=0$.

*Condition 3: If there exists a natural number $x$ such that $g_{a,b}(x)=0$, then $a,b$ are square numbers.
If it exists, then could you show me the example? If it doesn't exist, then could you prove that?
Motivation : I've tried to generalize the fact that for any $a\in\mathbb{N}$ there is a polynomial $f_a(x)=x^2-a$ such that 
$$\text{
"$a$ is a square number $\iff$ there exists a natural number $x$ such that $f_a(x)=0$."
}$$
This got me interested in finding an integer-coefficients polynomial $g_{a,b}(x)$ which satisfies conditions 2 and 3. I was able to find this $4^\text{th}$ degree polynomial:
\begin{align*}
g_{a,b}(x) &=x^4-2(a+b)x^2+(a-b)^2. \\ \\
&=(x-\sqrt a-\sqrt b)(x+\sqrt a+\sqrt b)(x+\sqrt a-\sqrt b)(x-\sqrt a+\sqrt b)
\end{align*}
We can show that this example satisfies the two conditions.

Proof : First, since $a,b$ are square numbers $\Rightarrow$ $\sqrt a+\sqrt b$ is a natural number, then, letting $x=\sqrt a+\sqrt b$, we get $g_{a,b}(x)=0.$ On the other hand, if $g_{a,b}(x)=0$, then we get $x=\pm\sqrt a\pm\sqrt b.$ (four possibilities)
Hence we get
  $$x^2\mp2x\sqrt a+a=b$$
  $$x^2+a-b=\pm2x\sqrt a$$
  $$(x^2+a-b)^2=4x^2a.$$

After getting this, I've tried to find a similar polynomial of smaller degree, but I can neither find it nor prove that there is no such polynomial. Can anybody help?
 A: $\def\QQ{\mathbb{Q}}\def\ZZ{\mathbb{Z}}$I can establish the following:
Theorem Let $g(a,b,x)$ be a polynomial in $\mathbb{Q}(a,b,x)$. Suppose that $g$ has a rational root in $x$ if and only if $a$ and $b$ are rational squares. Then $\deg_x g \geq 4$. 
I am about 95% sure I can modify the proof to work with integer squares, and will come back and post such a modified version when I have the time.

Suppose that $g(a,b,x) \in \QQ(a,b,x)$ and that, whenever $a$ and $b$ are integer squares then $g(a,b,x)$ has a rational root. (I have deliberately chosen the weakest combination of $\QQ$ and $\ZZ$ for my hypotheses, so the result is as strong as possible.) I will show that at least one of the following is true.


*

*$g(u^2,b,x)$ has a rational root for all $(u,b) \in \mathbb{Q}^2$.

*$g(a,v^2,x)$ has a rational root for all $(u,b) \in \mathbb{Q}^2$.

*$g(a,a w^2,x)$ has a rational root for all $(a,w) \in \mathbb{Q}^2$.

*$\deg_x g \geq 4$.


Set $h(u,v,x) = g(u^2,v^2,x)$. So $h(u,v,x)$ has an integer root for every $x$. Let $h(u,v,x) = \prod_i h_i(u,v,x)$ be the factorization of $h$ into irreducibles.
Lemma At least one of the $h_i$ has $x$-degree $1$. 
Proof: If $\deg_x h_i \geq 2$ then, Hilbert's irreducibility theorem tells us that $h_i$ has no rational  roots for "most" values of $(u,v)$. More precisely, by a result of Cohen, the number of integer $(u,v)$ in $[-N,N]^2$ for which $h_i(u,v)$ has a rational root will be $O(N^{3/2} \log N)$.
So, if all the $h_i$ had degree $\geq 2$, then $\mathbb{Z}^2$ would be the union of finitely many sets, each of which only has $O(N^{3/2} \log N)$ points inside a box of side length $N$, a contradiction. $\square$.
So, let $h_i$ have $x$-degree $1$ and write $h_i(u,v,x) = q(u,v) x - p(u,v)$. Let $r(u,v)$ be the rational function $p(u,v)/q(u,v)$.
Consider the field extension $\mathbb{Q}(u,v)/\mathbb{Q}(a,b)$ where $a=u^2$ and $b=v^2$. This is Galois with Galois group $(\mathbb{Z}/2)^2$. So there are three intermediate subfields: $\mathbb{Q}(u,b)$, $\mathbb{Q}(a,v)$ and $\mathbb{Q}(a,w)$ where $w=v/u$. If $r$ is not in any of these intermediate fields, then the minimal polynomial of $r$ over $\mathbb{Q}(a,b)$ has degree $4$. This minimial polynomial divides $g$, so $\deg_x g\geq 4$.
We now consider the case that $r(u,v) \in \mathbb{Q}(u,b)$ or, in other words, $r(u,v)$ is $s(u,v^2)$ for some rational function $s$. For any $(u,b)$ in $\QQ^2$, the quantity $r(u, \sqrt{b})$ is a root of $g(u^2, b,x)$. But $r(u, \sqrt{b}) = s(u,b)$, so it is rational, and we have shown that $g(u^2,b,x)$ has a rational root for any $(u,b) \in \mathbb{Q}^2$.  
Similarly, if $r(u,v)$ is in $\mathbb{Q}(a,v)$ then $g(a,v^2,x)$ has a rational root for every $(a,v)$ and, if $r(u,v)$ is in $\mathbb{Q}(a,v/u)$ then $g(a,aw^2 x)$ has a rational root for any $(a,w)$.
