This is the fastest I could come up with. Instead of putting the constraint {1, -1}
on the variables at the outset, I let Reduce
work over all reals but modify the equations to contain only the Sign
of all the variables.
This yields a lot of logical conditions, but they are produced very fast. At the end, ToRules
helps convert the conditions into a form that can be used by Simplify
to get a list of allowed Sign
values for the list of variables var
. WIthout the initial constraints, I get zeros in the result, too, which can easily by weeded out by Select
:
vars = {a1, a2, a3, a4, b1, b2, b3, b4};
solutions = Select[
Simplify[Sign /@ vars, #] & @@@ {ToRules[
Reduce[{Sign /@ (a1*a2*a3*b4 + a1*a2*b3 + a1*b2 + b1) == 0,
Sign[a1*a2*a3*a4] == 1}, vars, Reals]]}, FreeQ[#, 0] &]
(*
==> {{-1, -1, -1, -1, -1, -1, -1, -1}, {-1, -1, -1, -1, -1, -1,
1, 1}, {-1, -1, -1, -1, -1, 1, 1, -1}, {-1, -1, -1, -1, 1, -1, -1,
1}, {-1, -1, -1, -1, 1, 1, -1, -1}, {-1, -1, -1, -1, 1, 1, 1,
1}, {-1, -1, 1, 1, -1, -1, -1, 1}, {-1, -1, 1, 1, -1, -1,
1, -1}, {-1, -1, 1, 1, -1, 1, 1, 1}, {-1, -1, 1, 1,
1, -1, -1, -1}, {-1, -1, 1, 1, 1, 1, -1, 1}, {-1, -1, 1, 1, 1, 1,
1, -1}, {-1, 1, -1, 1, -1, -1, -1, -1}, {-1, 1, -1, 1, -1, -1, 1,
1}, {-1, 1, -1, 1, -1, 1, -1, 1}, {-1, 1, -1, 1, 1, -1, 1, -1}, {-1,
1, -1, 1, 1, 1, -1, -1}, {-1, 1, -1, 1, 1, 1, 1, 1}, {-1, 1,
1, -1, -1, -1, -1, 1}, {-1, 1, 1, -1, -1, -1, 1, -1}, {-1, 1,
1, -1, -1, 1, -1, -1}, {-1, 1, 1, -1, 1, -1, 1, 1}, {-1, 1, 1, -1,
1, 1, -1, 1}, {-1, 1, 1, -1, 1, 1, 1, -1}, {1, -1, -1,
1, -1, -1, -1, 1}, {1, -1, -1, 1, -1, 1, -1, -1}, {1, -1, -1, 1, -1,
1, 1, 1}, {1, -1, -1, 1, 1, -1, -1, -1}, {1, -1, -1, 1, 1, -1, 1,
1}, {1, -1, -1, 1, 1, 1, 1, -1}, {1, -1,
1, -1, -1, -1, -1, -1}, {1, -1, 1, -1, -1, 1, -1, 1}, {1, -1,
1, -1, -1, 1, 1, -1}, {1, -1, 1, -1, 1, -1, -1, 1}, {1, -1, 1, -1,
1, -1, 1, -1}, {1, -1, 1, -1, 1, 1, 1, 1}, {1, 1, -1, -1, -1, -1,
1, -1}, {1, 1, -1, -1, -1, 1, -1, -1}, {1, 1, -1, -1, -1, 1, 1,
1}, {1, 1, -1, -1, 1, -1, -1, -1}, {1, 1, -1, -1, 1, -1, 1, 1}, {1,
1, -1, -1, 1, 1, -1, 1}, {1, 1, 1, 1, -1, -1, 1, 1}, {1, 1, 1,
1, -1, 1, -1, 1}, {1, 1, 1, 1, -1, 1, 1, -1}, {1, 1, 1, 1,
1, -1, -1, 1}, {1, 1, 1, 1, 1, -1, 1, -1}, {1, 1, 1, 1, 1,
1, -1, -1}}
*)