Algorithm to Find Integer Solutions of Square Root

159 Views Asked by At

I have equations, when finally I have to find integer solutions (at least few) to something like this:
$y = \sqrt{ax^2 + bx + c}$
where b and c can be huge (30 - 40 decimal digits, maybe more, not sure now). Is there any way to speedup process, making algorithm effective (apart of brute force search)?
Edit: y is a variable too

1

There are 1 best solutions below

5
On

from $y^2 = a x^2 + b x + c,$ as long as $a$ is positive but not a square, we get $$4ay^2 = 4 a^2 x^2 + 4abx + 4ac= 4 a^2 x^2 + 4 a b x + b^2 -(b^2 - 4ac),$$ $$ 4 a y^2 = (2ax+b)^2 - (b^2 - 4ac), $$ $$ (2ax + b)^2 - 4 a y^2 = b^2 - 4ac, $$ $$ w^2 - 4 a y^2 = n, $$ where $n = b^2 - 4 a c.$ There are two ways that this might be tractable. In one case, if $|n|$ is really small, then we can find $(w,y)$ pairs by methods that are equivalent to continued fractions. The other extreme is when $|n| = p$ is prime and Legendre symbol $(a|p) = 1.$

The general name here is Pell equations. With large numbers, there is no guarantee that solutions can be found.