0
$\begingroup$
   lst1 = {x1, 123, x1 + x2, x2^5, x3^2, 4 x1 - x2, 4/5, (x2 + x4)^2, 1/x4, 1/(x1 + x3)};

How can I pick up the some kind of multinomial from lst1 and get lst2 in a simple way,

lst2 = { x1 + x2, 4 x1 - x2, (x2 + x4)^2, 1/(x1 + x3)};
$\endgroup$
  • 2
    $\begingroup$ 1/(x1 + x3) is not a multinomial. Are you trying to filter expressions that depend on two or more variables? $\endgroup$ – J. M. will be back soon Mar 30 '17 at 9:38
  • $\begingroup$ @J.M. Yes, that's the point. Thanks! $\endgroup$ – Orders Mar 30 '17 at 12:02
3
$\begingroup$

If the aim is to extract multivariate expressions:

Pick[lst1, Length[Variables@#] > 1 & /@ lst1]

or as per J.M.:

Select[lst1, Length[Variables@#] > 1 &]
$\endgroup$
  • $\begingroup$ Select[] is better here, methinks. $\endgroup$ – J. M. will be back soon Mar 30 '17 at 9:47
  • $\begingroup$ ...and if one wants to cover nonpolynomial expressions, use Reduce`FreeVariables[] as in this answer. $\endgroup$ – J. M. will be back soon Mar 30 '17 at 9:57
  • $\begingroup$ @J.M. thanks for the instructive comments $\endgroup$ – ubpdqn Mar 30 '17 at 9:58

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.