My code needs to check whether a lot of low-degree equations (usually quadratic and cubic) are solvable in integers. There are many equations, so the speed is crucial. Let us start with quadratic equations and, for test, consider 10,000 equations in the form $ax^2+bx+c=0$ where $a,b,c$ are random integers up to $10^{10}$. If I use standard command
Reduce[a x^2 + b x + c == 0, {x}, Integers]
then these equations are solved in total time 1.34. Alternatively, we can check whether the determinant $d=b^2-4ac$ is a perfect square. If for this I use
If[IntegerQ[Sqrt[d]]
command, then the total time becomes 0.53. However, I then searched online for the best way to check whether an integer is a perfect square and found the command
If[FractionalPart@Sqrt[d + 0``1] == 0,
With it help, all the equations are checked in just 0.047 second!
My question is whether a method with similar speed up comparing to Reduce exists for checking integer solvability for cubic equations $ax^3+bx^2+cx+d=0$, where $a,b,c,d$ are integer coefficients with about $10-30$ digits.
Solve
? For example, withd = {-824150223890338609745847277134931678957, 648037579, 685402538, 1436522590}
I find thatOr @@ IntegerQ /@ SolveValues[d . {1, y, y^2, y^3} == 0, y]
takes less than 4 milliseconds. $\endgroup$