6
$\begingroup$

I have some quadratics, and I am trying to find out whether there exist solutions in the integers. The following tells me that the first does, wheraeas the second doesn't:

Solve[2 + 4 x + 6 x^2 == 4 - 7 y + 3 y^2 && x < 0 && y < 0, x, Integers]
Solve[12 + 15 x + 9 x^2 == 4 - 7 y + 3 y^2 && x < 0 && y < 0, x, Integers]

This is fine. However, I am not particularly interested in what the solutions are, just whether a solution exists. I have a lot of these, and it is taking a long time to calculate, since it is trying to find a solution for each one.

Generally, if there isn't a solution, it spits out {} quite quickly (which is all I really want to know). Is it possible to find out whether such equations have integer solutions, without having to evaluate each one, and hence speed up calculation times?

$\endgroup$
2
  • $\begingroup$ Perhaps FindInstance? Can't guarantee that it's faster, though. Don't know too much about it. $\endgroup$
    – march
    Jan 4, 2016 at 18:14
  • $\begingroup$ @march Good suggestion. The two functions are comparable in run time for the two examples, but FindInstance gives a cleaner answer - no ConditionalExpression, Reduce is slightly faster then either for the example above when no solution exists. $\endgroup$
    – bbgodfrey
    Jan 4, 2016 at 19:12

1 Answer 1

1
$\begingroup$

I hope there is a better solution for you, but why not try something like this:

TimeConstrained[Solve[12 + 15 x + 9 x^2 == 4 - 7 y + 3 y^2 && x < 0 && y < 0, x, Integers], 0.01]

You might optimize the time to abort for your machine.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.