1 | initial version |
Is that what you need?
var('x y');
p=(x^2*y^2+x*y^2+x^3*y+x^4*y^4).polynomial(QQ)
sum([m for m in p.monomials() if forall(m.exponents()[0],lambda x:is_even(x))[0]])
#x^4*y^4 + x^2*y^2
2 | No.2 Revision |
Is that what you need?
var('x y');
p=(x^2*y^2+x*y^2+x^3*y+x^4*y^4).polynomial(QQ) p=(5*x^2*y^2+x*y^2+x^3*y+x^4*y^4).polynomial(QQ) sum([m sum([v[0]*v[1] for m v in p.monomials() p if forall(m.exponents()[0],lambda forall(v[1].exponents()[0],lambda x:is_even(x))[0]])
#x^4*y^4 + x^2*y^2
5*x^2*y^2