0
$\begingroup$

I convert here only one term $x_1x_3x_7$ from the binary matrix by first getting the reversed binary 1010001 and then miggling with the data. I know I could convert the columns into binaries and then use solutions here but I feel there must be something builtin: I am trying to convert binary form of multilinear function simply to its symbolic form where the MLF is expressed as a matrix below..

Is there anything built in to convert the binary matrix into the corresponding multilinear function?

Input

enter image description here

Intended output

$x_1x_3x_7+x_1x_3x_5x_6+x_1x_4x_7+x_1x_4x_5x_6-x_2x_3x_7-x_2x_3x_5x_6-x_2x_4x_7-x_2x_4x_5x_6$

$\endgroup$
2
$\begingroup$

I think you need something like this

Total[#1 - #2] & @@ Partition[#, Length[#]/2] &[
 Times @@ MapIndexed[Subscript[x, #2[[1]]]^# &, Boole[MCSs], {2}]]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ @hhh Transpose isn't necessary here. Without it the solution becomes more compact. See my update: I delete Transpose and use @@ instead of @@@. It works because Times has a Listable attribute. $\endgroup$ – ybeltukov Nov 10 '13 at 21:50
  • $\begingroup$ @hhh I think you need time to solve your problem. Not a hour, but a day or a week. After update this problem seems too narrow to the community (read: I don't understand it completely). $\endgroup$ – ybeltukov Nov 10 '13 at 22:12
  • 1
    $\begingroup$ @hhh - it is ok to have your contact information in your user profile, but please do not leave identifying information in comments. Also, if the issue can be solved that easily, it can be solved in chat. By definition, if a problem is solved by email, it is not then publicly available to help the community. Part of the rationale of this site is also to help future visitors with questions similar to those already posted, which email solutions do not do. $\endgroup$ – Verbeia Nov 11 '13 at 3:19
1
$\begingroup$
MCSs = {{1, 0, 1, 0, 0, 0, 1}, {1, 0, 1, 0, 1, 1, 0}, {1, 0, 0, 1, 0, 0, 1}, 
        {1, 0, 0, 1, 1, 1, 0}, {0, 1, 1, 0, 0, 0, 1}, {0, 1, 1, 0, 1, 1, 0}, 
        {0, 1, 0, 1, 0, 0, 1}, {0, 1, 0, 1, 1, 1, 0}};
var = Subscript[x, #] & /@ Range[7];

(Plus @@ Inner[#2^#1 &, MCSs[[;; 4]], var, Times]) - 
(Plus @@ Inner[#2^#1 &, MCSs[[5 ;;]], var, Times])

Mathematica graphics

Alternatively, one could use:

Plus @@ Times @@@ (Pick[var, #, 1] & /@ MCSs[[;; 4]]) -
Plus @@ Times @@@ (Pick[var, #, 1] & /@ MCSs[[5 ;;]])
$\endgroup$
  • $\begingroup$ You are correct! Inner[Power, Subscript[x, #] & /@ Range[7], {1, 0, 1, 0, 0, 0, 1}, Times] returns x_1x_3x_7, amazing! Now looping required, anyway excellent idea! So easy to read to consider zero/ones as powers ^-^ +1 $\endgroup$ – hhh Nov 10 '13 at 23:32
  • $\begingroup$ @hhh Power wouldn't be correct. You need its variables in reverse. $\endgroup$ – Sjoerd C. de Vries Nov 14 '13 at 13:17
1
$\begingroup$

FromCoefficientRules is an approach. Apologies for any transcription errrors. The MCSs matrix was an image not copyable code.

MCS = {{1, 0, 1, 0, 0, 0, 1}, {1, 0, 1, 0, 1, 1, 0}, {1, 0, 0, 1, 0, 
    0, 1}, {1, 0, 0, 1, 1, 1, 0}, {0, 1, 1, 0, 0, 0, 1}, {0, 1, 1, 0, 
    1, 1, 0}, {0, 1, 0, 1, 0, 0, 1}, {0, 1, 0, 1, 1, 1, 0}};

This matrix rows can be interpreted as ordered list of the exponents of multinomial term. Generate the variable list:

var = Subscript[x, #] & /@ Range[7];

Generate the rules for term->coefficient:

pos = Thread[MCS[[Range[4]]] -> 1];
neg = Thread[MCS[[Range[4] + 4]] -> -1];

UseFromCoefficientRules to assemble the multinomial:

FromCoefficientRules[Join[pos, neg], var]

yields:

Subscript[x, 1] Subscript[x, 3] Subscript[x, 5] Subscript[x, 6] - 
 Subscript[x, 2] Subscript[x, 3] Subscript[x, 5] Subscript[x, 6] + 
 Subscript[x, 1] Subscript[x, 4] Subscript[x, 5] Subscript[x, 6] - 
 Subscript[x, 2] Subscript[x, 4] Subscript[x, 5] Subscript[x, 6] + 
 Subscript[x, 1] Subscript[x, 3] Subscript[x, 7] - 
 Subscript[x, 2] Subscript[x, 3] Subscript[x, 7] + 
 Subscript[x, 1] Subscript[x, 4] Subscript[x, 7] - 
 Subscript[x, 2] Subscript[x, 4] Subscript[x, 7]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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