# 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

1

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

Example: https ://doc .sagemath .org

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^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^2; print(f^3) However I still get x0^6 here instead of an expected 0.

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()].

P = PowerSeriesRing(QQ, 3, 'x', default_prec = 3); x = [g.add_bigoh(3) for g in P.gens()]; f=P(x^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...

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.

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)


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