Ask Your Question
2

manipulation of multivariate polynomial

asked 2014-07-01 10:18:06 -0500

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.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2014-07-02 03:44:37 -0500

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
edit flag offensive delete link more

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 ( 2014-07-02 05:00:37 -0500 )edit
1

answered 2014-07-02 02:46:58 -0500

updated 2014-07-02 02:47:48 -0500

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

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

2 followers

Stats

Asked: 2014-07-01 10:18:06 -0500

Seen: 168 times

Last updated: Jul 02 '14