Ask Your Question
1

How to get a list of monomials of a given degree

asked 2012-05-22 23:43:08 +0200

paragon gravatar image

Is there a nice way to get all monomials of a given degree in a multivariable polynomial ring?

For example I want to input x,y,3 and get

x^3, x^2y, xy^2, y^3.

I think I could code it myself with not too much work, but it seems like something that might already have a nice method.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
3

answered 2012-05-23 00:08:32 +0200

I don't think there is a method that allows you to do this. This is one step away:

sage: list(WeightedIntegerVectors(3, [1,1]))
[[0, 3], [1, 2], [2, 1], [3, 0]]

(This gives all lists of integers [a,b] so that 1*a + 1*b = 3.) So:

sage: R.<x,y> = PolynomialRing(QQ, 2)
sage: degs = WeightedIntegerVectors(3, [1,1])
sage: [x^d[0] * y^d[1] for d in degs]
[y^3, x*y^2, x^2*y, x^3]
edit flag offensive delete link more
1

answered 2013-08-15 22:15:12 +0200

nbruin gravatar image

You can map exponent vectors more directly to monomials:

sage: P.<x,y,z>=QQ[]
sage: [P({tuple(a):1}) for a in WeightedIntegerVectors(3,[1,1,1])]
[z^3, y*z^2, x*z^2, y^2*z, x*y*z, x^2*z, y^3, x*y^2, x^2*y, x^3]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-05-22 23:43:08 +0200

Seen: 2,749 times

Last updated: Aug 15 '13