Square of polynomial I have a problem with the following task.  
Let $W(n) := an^2 + bn + c$ where $a,b,c \in \mathbb{Z}$.
Assume that for all $n \in \mathbb Z$ we have that $W(n)$ is the square of an integer.
Show that there exists some $P$ such that $W(n) = P(n)^2$.
Thanks for any tips or help.
John 
 A: Without loss of generality, you can assume $a,b,c\geq 0$. Since
$$ 4a W(x) - (2ax+b)^2 = 4ac - b^2 = D, $$
we have that the Pell equation
$$ 4a u^2 - v^2 = D, $$ 
for any $N$ big enough, has at least $\left\lfloor\frac{N}{2a}\right\rfloor$ integer solutions $(u,v)$ with $|v|\leq N$. From the theory of Pell equation we know that, if $D\neq 0$, there are at most $O(\log N)$ solutions with $|v|\leq N$, so 
$$ D=0, \quad a=A^2, \quad c=W(0)=C^2, \quad W(x)=(Ax+C)^2 $$  
must hold.
A: We have a (possibly nonpolynomial) function $w\colon\mathbb Z\to \mathbb N_0$ such that $W(x)=w(x)^2$ for all $x\in \mathbb Z$.
If $a<0$ then $W(x)<0$ for sufficiently big $x$. Hence $a\ge 0$.
If $a=0$ and $b\ne 0$, then again $W(x)<0$ for suitable $x$. Hence $a=0$ implies $b=0$, but then $W(x)=W(0)=(w(0))^2$ as desired.
Therefore we may assume for the rest of the argument that $a\ne 0$.
If $x$ is big, then $w(x)\approx x\sqrt a$.
More precisely, if $\alpha,\beta$ are positive real numbers, then from
$\alpha^2-\beta^2=(\alpha-\beta)(\alpha+\beta)$ we see that   $|\alpha-\beta|\le\frac{|\alpha^2-\beta^2|}\alpha$.
Therefore, from $(x\sqrt a+\frac{b}{2\sqrt a})^2-w(x)^2=\frac{b^2}{4a}-c$, we conclude $$\tag1w(x)=x\sqrt a +\frac b{2\sqrt a}+O(x^{-1}).$$
If $b=c=0$, then $a=w(1)^2$ and we have $W(x)=(w(1)x)^2$ as desired.
Therefore we may assume that $b\ne0$ or $c\ne 0$, hence we can consider $d=\gcd(b,w(0))$ and write $b=du$, $c=d^2v^2$ with $u,v\in\mathbb Z$.
Then if $p|v$, we have that $W(p)=ap^2+dup+c$ is a multiple of $p$, but not of $p^2$, contradicting squareness. 
Consequently, $v=1$, $d=w(0)$, $c=d^2$ and $d|b$. 
As $W(\pm d)=ad^2\pm ud^2+d^2$ is divisible by $d^2$, we see that $w(\pm d)$ is divisible by $d$ and  $2u=\left(\frac {w(d)}{d}\right)^2-\left(\frac{w(-d)}{d}\right)$ is the difference of two squares.
But if a difference of squares is even, it is also a multiple of four.
We conclude that $u$ is even.
Therefore write $b=2dh$ with $h\in\mathbb Z$. 
Then $$\tag2W(x) = ax^2+2dhx+d^2=(hx+d)^2+(a-h^2)x^2.$$
Thus if $h^2=a$, we are done. Therefore assume that $h\ne \pm\sqrt a$.
From $(2)$ we obtain
$(a-h^2)x^2=(w(x)+hx+d)(w(x)-hx-d)$.
Thus $(a-h^2)x^2$ has factors $w(x)+hx+d=(\sqrt a +h)x+O(1)$ and $w(x)-hx-d=(\sqrt a -h)x+O(1)$. As $x\to \infty$, both factors are unbounded, hence for a large enough prime $x$, each factor exceeds $a^2-h$ (in absolute value) and hence must be divisible by $x$ (but not $x^2$).
After dividing out $x$, this implies that $a-h^2$ has integer factors $\sqrt a +h+O(x^{-1})$ and  $\sqrt a -h+O(x^{-1})$. 
As $x$ can grow arbitrary large, $\sqrt a\pm h$ must be integer, especially $n:=\sqrt a$ is an integer.
But then from $(1)$ we have $\frac{b}{2n}=w(x)-nx+O(x^{-1})$ and this implies that $m:=\frac{b}{2n}$ is an integer because $w(x)-nx$ is an integer and $O(x^{-1})$ arbitrarily small.
We obtain $W(x)=(n x+m)^2+c-m^2$, hence $c-m^2 = (w(x)-nx-m)(w(x)+nx+m)$.
The second factor is unbounded hence the first factor becomes arbitrarily small. 
But as it is an integer, this means that it becomes $0$ for large $x$.
Therefore $c=m^2$ and
$$W(x)=(n x+m)^2.$$
A: $W(x) = ax^2 + bx + c$ is analytic and positive over the positive reals so it's square root $F(x)$ is also. Set $C$ to be the integer $F(0)$ and note that $c = C^2$. The functions $F$ and $W$ have the same set of roots but a root of $F$ is a double root of $W$ thus $b^2 = 4aC^2$ this implies some integer $A$ such that $a^2 = A$ hence $W(x) = A^2 x^2 + 2AC x + C^2 = (Ax+C)^2$.
