# Multivariate polynomial ring with total degree no larger than n

Hello everyone,

I need to compute the product: $f(x_1) f(x_2) ... f(x_n)$, where $f$ is a polynomial of degree $n$, and I do not need the part with total degree larger than $n$. To reduce the computation complexity, I think it would be helpful to construct an $n$-variable multivariate polynomial ring, with terms total degree no larger than $n$. I found the following two possible ways to do this, however, I could not make either of them work for my settings.

1. Create a multivariate polynomial ring then quotient out every monomial with total degree larger than $n$. However I do not know how to express this ideal.

Q = PolynomialRing(QQ, n, 'x')
x = Q.gens()

2. I found a suggestion to use a function max_degree for polynomial rings at

However, it seems there is no max_total_degree function for the multivariate case.

edit retag close merge delete

( 2022-03-12 18:09:31 +0200 )edit
1

To post links as a new user, insert spaces in them. Someone can then fix them.

Example: https ://doc .sagemath .org

( 2022-03-12 18:10:33 +0200 )edit

( 2022-03-13 01:52:44 +0200 )edit

Sort by » oldest newest most voted

Ignoring parts with total degree $\geq d$ suggests that power series with precision $d$ are more suitable in this setting:

d = 3
Q = PowerSeriesRing(QQ, 3, 'x', default_prec=d)
x = [g.add_bigoh(d) for g in Q.gens()]
f = x[0]^4

more

Thank you for your answer! I tried the following code: Q = PowerSeriesRing(QQ, 3, 'x', default_prec = 3); x = Q.gens(); f = x[0]^2; print(f^3) However I still get x0^6 here instead of an expected 0.

( 2022-03-13 02:00:57 +0200 )edit

It turns out generators do not inherit default precision, so it needs to be added explicitly. In your example, it would be x = [g.add_bigoh(3) for g in Q.gens()].

( 2022-03-13 03:17:18 +0200 )edit

P = PowerSeriesRing(QQ, 3, 'x', default_prec = 3); x = [g.add_bigoh(3) for g in P.gens()]; f=P(x[0]^4); f

The above code still yields x0^4 + O(x0, x1, x2)^6 instead of 0. Also, since I need to convert the product into symmetric polynomials afterwards, the introducing of the big O seems cause more trouble...

( 2022-03-13 08:20:20 +0200 )edit

The reason is that Sage tries to keep precision as large as possible, and for the 4th power the precision becomes 6. It can be always decreased by .add_bigoh() and the resulting series can be converted into a polynomial via .polynomial() method. I've updated an example in my answer accordingly.

( 2022-03-13 15:58:06 +0200 )edit

Thank you very much for your answer! It works fine now. By the way, do you know how to fix this problem under your settings?

g(y) = y^2; g(x[0])


This code used to work when Q is a polynomial ring, but it seems get some trouble when Q is a power series ring.

( 2022-03-14 16:50:24 +0200 )edit