First time here? Check out the FAQ!

Ask Your Question
2

manipulation of multivariate polynomial

asked 10 years ago

rws gravatar image

Hello, I have an expression that comes from expanding a product of polynomials in one variable each. For demonstration purposes I'm using the Symbolic Ring but the question is not specific to it:

sage: var('a,b')
(a, b)
sage: ex=(1+a+a^2+a^3)*(1+b+b^2+b^3)
sage: ex.expand()
a^3*b^3 + a^3*b^2 + a^2*b^3 + a^3*b + a^2*b^2 + a*b^3 + a^3 + a^2*b + a*b^2 + b^3 + a^2 + a*b + b^2 + a + b + 1

Is there a nice way to get a new expression from that which has only exponents <=3 when a and b are seen as identical? The above product would then yield:

a^3 + a^2*b + a*b^2 + b^3 + a^2 + a*b + b^2 + a + b + 1

that is, for example a*b^3 is removed because it has combined exponent 4.

I'm looking for a way to achieve this without writing a loop that goes through all terms.

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 10 years ago

rws gravatar image

I meanwhile found that in the ring of multivariate power series the above product can be truncated using bigoh with two arguments:

sage: R.<a,b> = PowerSeriesRing(QQ); R
Multivariate Power Series Ring in a, b over Rational Field
sage: (1+a+a^2+a^3)*(1+b+b^2+b^3)+O(a,b)^4
1 + a + b + a^2 + a*b + b^2 + a^3 + a^2*b + a*b^2 + b^3 + O(a, b)^4
Preview: (hide)
link

Comments

I think (but am not sure) that both the big-O and .mod use a loop over terms internally, but it sounds like that's ok with you.

niles gravatar imageniles ( 10 years ago )
1

answered 10 years ago

vdelecroix gravatar image

updated 10 years ago

I have a loop but not through the terms

sage: R.<a,b> = ZZ[]
sage: f=(1+a+a^2+a^3)*(1+b+b^2+b^3)
sage: f.mod([a^i*b^(4-i) for i in xrange(5)])
a^3 + a^2*b + a*b^2 + b^3 + a^2 + a*b + b^2 + a + b + 1

Vincent

Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 10 years ago

Seen: 581 times

Last updated: Jul 02 '14