Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Performing substitutions on powers of a variable

I have some polynomials of degree $d$ and I would like to obtain the monomial where all exponents greater than $1$ are reduced to $1$. For example $x_1^2 x_3^4 x_2 + x_1^7x_3^3 x_2^8 + \cdots$ would become $2x_1 x_3 x_2 + \cdots $

Naively, I thought an approach along the following lines would work:

sage: x = PolynomialRing(QQ, 1, 'x').objgens()[1][0]
sage: s = 2*x^2
sage: s.substitute({x^2:x})
2*x^2

Unfortunately, this does not give the proper result. Hence I am wondering

What is the proper way to perform the described substitution on the powers of a given monomial?

Performing substitutions on powers of a variable

I have some polynomials of degree $d$ and I would like to obtain the monomial where all exponents greater than $1$ are reduced to $1$. For example $x_1^2 x_3^4 x_2 + x_1^7x_3^3 x_2^8 + \cdots$ would become $2x_1 x_3 x_2 + \cdots $

Naively, I thought an approach along the following lines would work:

sage: x = PolynomialRing(QQ, 1, 'x').objgens()[1][0]
sage: s = 2*x^2
sage: s.substitute({x^2:x})
2*x^2

Unfortunately, this does not give the proper result. Hence I am wondering

What is the proper way to perform the described substitution on the powers of a given monomial?

Performing substitutions on powers of a variable

I have some polynomials of degree $d$ and I would like to obtain the monomial where all exponents greater than $1$ are reduced to $1$. For example $x_1^2 x_3^4 x_2 + x_1^7x_3^3 x_2^8 + \cdots$ would become $2x_1 x_3 x_2 + \cdots $

Naively, I thought an approach along the following lines would work:

sage: x = PolynomialRing(QQ, 1, 'x').objgens()[1][0]
sage: s = 2*x^2
sage: s.substitute({x^2:x})
2*x^2

Unfortunately, this does not give the proper result. Hence I am wondering

What is the proper way to perform the described substitution on the powers of a given monomial?

Edit. It seems that I can do ss = symbolic_expression(s).substitute({x^2:x}) and then convert ss to a polynomial. However, this seems to be extremely inefficient.