I have a polynomials of multivariable for instance: $P=yx+2^4xy+3+5^2xz+3^4zx $

Now I would like to do the following:

  1. extract those temrs that only has $z$ .

  2. extract terms that only has $y$

  3. express my polynomial with something like this: $P=z(...)+y(...)+(some constants)$

I knoe its quite easy but this is just an example what I want to do in real is a polynomial with 60 terms in it so i would like to know the procedure for doing this.

  • $\begingroup$ tried Collect? $\endgroup$ – kglr Jul 11 at 9:14
  • $\begingroup$ Your example is bad since in fact the polynomial is 3 + 17 x y + 106 x z, which remains the same after vars = Variables[P];Collect[P, Rest[vars], Factor] $\endgroup$ – user18792 Jul 11 at 9:17
  • $\begingroup$ @ user18792 the answer to this example is straightforward and supposed to be $P=z(3^4x+5^2x)+y(x+2^4x)+3$ $\endgroup$ – Jason Jul 11 at 9:20
  • $\begingroup$ @ kglr Thanks it worked $\endgroup$ – Jason Jul 11 at 11:51

You can use Collect:

poly = Inactivate[y x + 2^4 x y + 3 + 5^2 x z + 3^4 z x, Power]
Collect[poly, {y, z}]

enter image description here


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.