# Solving a polynomial where variables are constrained to take only some values

I want to find out which combinations of 1's and 0's would make this kind of equation be null:

    Ese2[x1_, x2_, x3_,  x7_] := (x2 (-0.00195313 + (0.0175781 - 0.015625 x2) x2^2 +
x1^3 (-0.015625 + (0.140625 - 0.125 x2) x2^2)) + (0.0175781 -
0.015625 x2 + (0.123047 - 0.125 x2) x2^3 +
x1^3 (-0.0175781 - 0.125 x2 - 0.28125 x2^3 -
1. x2^4)) x7^3)/(T (0.125 + x1^3) (0.125 + x2^3) (0.125 +
x7^3))


Where T is a parameter but I chose it to be 1.

I have tried solving over all the integers with Solve[Ese2[x1, x2, x3, x7] == 0, {x1, x2, x7}] and sometimes get a solution, that matches the pattern. Nevertheless, it takes too much time and it would be best to inform the algorithm that the x's can only take the value 0 or 1.

I am aware that i can impose certain conditions via other equalities like x1^2+5x2==3 && x1==0 but I don't know how to let x be 1 or 0.

• you have just four variables, it makes 2^4 combinations of zero or ones. So generate all combinations Tuples[{0, 1}, 4] and then plug them into your equation to check if any give zero. – BlacKow May 24 '16 at 18:22
• What is Snai2? What is T? – David G. Stork May 24 '16 at 18:22
• Ah sorry... T is 1 and Snai2 is just another function of the same kind. Will edit so the doubts are clarified. – Ernesto Paas May 24 '16 at 18:28
• @ErnestoPaas With Solve: Solve[Ese2[x1, x2, x3, x7] == 0 && x1 (x1 - 1) == 0 && x2 (x2 - 1) == 0 && x3 (x3 - 1) == 0 && x7 (x7 - 1) == 0, {x1, x2, x3, x7}], or Solve[Ese2[x1, x2, x3, x7] == 0 && (x1 == 0 || x1 == 1) && (x2 == 0 || x2 == 1) && (x3 == 0 || x3 == 1) && (x7 == 0 || x7 == 1), {x1, x2, x3, x7}]. – user31159 May 24 '16 at 18:44
• Thanks to Xavier and @BlacKow, for both answers. I'll post an answer to my question with both comments in mind. – Ernesto Paas May 24 '16 at 18:53

The first one is to just generate all the possible combinations and plug them into the equation like this Tuples[{0, 1}, 4] /. List -> Ese2 (Thanks to BlacKow for this).
And the second one uses the || operator to impose the conditions as an equality. Solve[Ese2[x1, x2, x3, x7] == 0 && (x1 == 0 || x1 == 1) && (x2 == 0 || x2 == 1) && (x3 == 0 || x3 == 1) && (x7 == 0 || x7 == 1), {x1, x2, x3, x7}] (Thanks to Xavier for this approach)