# [✓] Solve/Reduce systems with an array of variables?

Posted 1 year ago
1010 Views
|
2 Replies
|
3 Total Likes
|
 As a simple example I want to reduce the equation d1+2*d2==2, where d1 and d2 are either 0 or 1. This is easy: In[147]:= Reduce[{d1 + 2 d2 == 2, d1 == 0 || d1 == 1, d2 == 0 || d2 == 1}, {d1, d2}] Out[147]= d1 == 0 && d2 == 1 But if I use an array d[i] instead of d1, d2 for the unknown variables, I cannot get it to work. The following seems to be syntactically correct, but it does not work: In[152]:= Reduce[{d[1] + 2 d[2] == 2, ForAll[i, d[i] == 0 || d[i] == 1]}, d] During evaluation of In[152]:= Reduce::nsmet: This system cannot be solved with the methods available to Reduce. Out[152]= Reduce[{d[1] + 2 d[2] == 2, \!$$\*SubscriptBox[\(\[ForAll]$$, $$i$$]$$(d[i] == 0 || d[i] == 1)$$\)}, d] Of course this example ist extremely simplified. I need some solution for a large d-Array of variables and some equation containing them.
2 Replies
Sort By:
Posted 1 year ago
 Quantifier elimination will not handle an index as a polynomial variable. Instead map the conditions over the variables. Reduce[Flatten[{d[1] + 2 d[2] == 2, Map[d[#] == 0 || d[#] == 1 &, Range[2]]}], d] (* d[2] == 1 && d[1] == 0 *)