5
$\begingroup$

I have a rather silly question, I assume:

I have a (nested) list of polynomials that I made from a matrix with the Minors command and I would like to make them into polynomial equations with a conjunction. So for instance, say the list is equal to {{f1,f2},{f3,f4}}, where f1,f2,f3,f4 are polynomials, then I want the following conjunction:

f1 == 0 && f2 == 0 && f3 == 0 && f4 == 0

I would like this to be as automated as possible. I wasn't able to find the appropriate way to do this yet. Can someone help me out here?

$\endgroup$

3 Answers 3

6
$\begingroup$

Here's one way:

f = Flatten[{{f1, f2}, {f3, f4}}];
And @@ Thread[f == 0]

f1 == 0 && f2 == 0 && f3 == 0 && f4 == 0

The Thread gives you a list of four equations, each equal to zero. The @@ applies the And function to the head of the List, essentially transforming the list into a collection of Ands.

$\endgroup$
3
$\begingroup$
f = Flatten[{{f1, f2}, {f3, f4}}];

Inner[Equal, f, 0 & /@ f, And]

f1 == 0 && f2 == 0 && f3 == 0 && f4 == 0

$\endgroup$
2
$\begingroup$

Assuming a somewhat general case, where the rhs for each list is possibly different and different operators are applied to every list, the following segment

With[{minors = {{f1, f2}, {f3, f4}}},
 Block[{rhs = {{a, b}, {c, d}}, opers = {And, Or}},
  oper @@ MapThread[#3 @@ Thread[Equal[#1, #2]] &, {minors, rhs, opers}]
  ]
 ]

returns

oper[f1 == a && f2 == b, f3 == c || f4 == d]

When rhs={0,0},{0,0}} and opers={And,And}, oper=And then we get the requested output ie

f1 == 0 && f2 == 0 && f3 == 0 && f4 == 0
$\endgroup$

Your Answer

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

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