# Factorization of multivariable polynomial

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

I would like to do the following:

1. extract those terms that only have $$z$$

2. extract terms that only have $$y$$

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

I know it's quite easy but this is just an example what I want to do. In reality, I have a polynomial with 60 terms, so I would like to know the procedure for doing this.

• tried Collect?
– kglr
Jul 11 '19 at 9:14
• 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]
– Acus
Jul 11 '19 at 9:17
• @ user18792 the answer to this example is straightforward and supposed to be $P=z(3^4x+5^2x)+y(x+2^4x)+3$ Jul 11 '19 at 9:20
• @ kglr Thanks it worked Jul 11 '19 at 11:51