# Diophantine equation question concerning squares

How many squares there are of the form $d^2={b}^{2}-4ac$ if $a ,b ,c ,d$ are natural numbers between $1$ and $n$ such that $0\le{b}^{2}-4ac$? My first approach is for $d$, that must be an square of the form ${(b-2k)}^{2}$ for some natural $k$, but I'm stuck as I do not have much experience solving diophantine equations. As you can see, an equivalent question would be: how many parabolas of the form $a{x}^{2}+bx+c$ have rational solutions if $a,b,c$ are naturals numbers?What do you think?

-
A simple expression may not be achievable. One can use $(b-d)(b+d)=4ac$ to get an expression (using summantion). And one can get estimates. Once did this to show that "most" quadratics do not factor nicely. Don't remember details. – André Nicolas Jul 29 '12 at 23:19

This is equivalent to asking how many ways can $(b^2-d^2)/4$ be factored into two integers between $1$ and $n$. Here is some heuristic reasoning that can be made more precise:
Very roughly, $b^2-d^2$ behaves like a random number of size about $n^2$, and this has about $2 \log(n)$ divisors on average. Even after discarding the divisors that are larger than $n$, we should still get an average of $\asymp \log n$ solutions as $b$ and $d$ vary.
If we apply a little more analytic machinery, it should be possible to extract an asymptotic of the form $C n^2 \log n + O(n^2)$ where $C$ is an explicit constant. As André Nicolas commented, an exact closed formula with no error term is too probably much to ask. Even getting the constant $C$ might not be nice: a similar question I worked on gave a constant of the form $(a\sqrt{2} + b + c\log(\sqrt{2}+1))/\pi^2$.