# multivariate polynomial - extract several variables?

78 views

### Jeff

Dec 25, 2009, 9:43:13 AM12/25/09
to sage-support
Sage support,

I need to extract several variables from multivariate polynomials.
Here's an example.

Suppose I want to express

p = w^3*z^2*x^4*y + w^3*z^2 - 3*w^2*z*x^3 + 2*w^2*z*x

as a polynomial in w. Then I can call

p.polynomial(w)

and obtain

(z^2*y*x^4 + z^2)*w^3 + (-3*z*x^3 + 2*z*x)*w^2

But for me it's not always enough to extract a single variable. I
need to be able to call something like

p.polynomial(w, z)

and obtain

(y*x^4 + 1)*w^3*z^2 + (-3*x^3 + 2*x)*w^2*z

It's clear that I could call polynomial() repeatedly to accomplish
this, but if there's already some machinery that makes this easy I'd
like to use it. So what is the best approach?

Thanks in advance for the help.

Jeff

### Jeff

Dec 25, 2009, 2:46:55 PM12/25/09
to sage-support
Everyone,

Sorry for the noise - I realized this is utterly trivial.

BTW, sage is one of the best tools I have ever used. You guys have
done a huge service to the mathematics community.

Jeff