# Parity and number of squares taken by polynomials in a range?

I have a polynomial $f(x)=a^2x^2+bx+c\in\mathbb Z[x]$ with $f(x)$ not a constant times a square and $abc\neq0$ and I want to know how many $x$ between $-a$ and $a$ the polynomial is a perfect square. Since leading coefficient is a perfect square by this reference the polynomial only has finitely many squares.

1. How many squares can be achieved by $f(x)$ with $x\in(-a,a)\cap\mathbb Z$ if $|a|^6,|b|^4,|c|^3$ are roughly of similar size? Gap between squares is squareroot in size and $(x-y)|(f(x)-f(y))$ makes me think there is at most only $1$ square with $x\in(-a,a)\cap\mathbb Z$.

2. Is there a way to test in polynomial time the parity of number of square $f(x)$ with $x\in(-t,t)\cap\mathbb Z$ at any given $t<a$ or find at least one such square?

Is there any good reference on the topic? It suffices to compute $\sum_{x=-t}^t\omega(f(x))\bmod 2$ where $\omega(f(x))$ is number of divisors of $f(x)$.

## 1 Answer

The question can be equated to the counting of solutions to the following diophantine equation: $$4a^4x^2\pm y^2=\Delta_f,$$ where $\Delta_f=b^2-4a^2c$ and plus\minus relate to considering when $f(x)=-\square$ or $\square$. This follows from the fact that if $\pm \square=a^2x_1^2+bx_1+c$, then substituting $x=x_1+\frac{b}{2a^2}$ and clearing the denominator we get the above equation.

In the special case when $a=1$ more can be said. In particular, for counting negatives squares, there are known formulas for the $r_2(\Delta_f)$.

• The perfect square solutions correspond to the integer solutions to the equation $\Delta_f=x^2+y^2$, i.e. $2r'_2(\Delta_f)$. Given that we require a squarefree discriminant, we cannot have any prime divisors that are congruent to $3 \pmod{4}$. – pavl0 Aug 15 '18 at 8:19
• 'The perfect square solutions correspond to the integer solutions to the equation $\Delta_f=x^2+y^2\dots$' why? I do not see this. – 1.. Aug 15 '18 at 9:17
• If $f(z)=-\square$ (note that f(z) is always negative for $z\in (\alpha_1,\alpha_2)$), then letting $z'=z+\frac{b}{2}$, we get $f(z)=z'^2-\frac{\Delta_f}{4}$, thus $\frac{\Delta_f}{4}=\square+z'^2.$ – pavl0 Aug 15 '18 at 12:14
• $f(z)$ is $f(x)$ evaluated at $z$. For example, $f(x)=x^2-3x+1$, then $f(1)=-1$. (Also, I assumed that $f(x)$ is irreducible.) – pavl0 Aug 15 '18 at 16:45
• I do not see the connection en.wikipedia.org/wiki/Ramanujan–Nagell_equation#Equations_of_Ramanujan–Nagell_type or the reduction. – 1.. Aug 16 '18 at 8:02