Ask Your Question

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

edit retag close merge delete

## 1 Answer

Sort by » oldest newest most voted

You should work modulo the ideal generated by the $x_i^2-x_i$:

sage: R = PolynomialRing(QQ,3,'x') ; R
Multivariate Polynomial Ring in x0, x1, x2 over Rational Field
sage: R.inject_variables()
Defining x0, x1, x2
sage: I = R.ideal([m^2-m for m in R.gens()]) ; I
Ideal (x0^2 - x0, x1^2 - x1, x2^2 - x2) of Multivariate Polynomial Ring in x0, x1, x2 over Rational Field
sage: P = x1^2*x2^4 + 7*x0*x1^4*x2^5 - 12*x0*x2^7 ; P
7*x0*x1^4*x2^5 - 12*x0*x2^7 + x1^2*x2^4
sage: P.mod(I)
7*x0*x1*x2 - 12*x0*x2 + x1*x2

more

## Comments

Thanks. Just out of curiosity - is there a reason in the different behavior of substitute on symbolic expressions and polynomials?

2

Polynomials and symbolic expressions are not the same objects at all, in particular they are not implemented the same way. Also, quotient ring does not makes much sense for general symbolic expressions.

If you have to deal with polynomials, i strongly encourage you to work with polynomial rings instead of symbolic expressions. They are more reliable and much faster.

## Your Answer

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

Add Answer

## Stats

Asked: 2016-03-20 21:03:35 +0200

Seen: 164 times

Last updated: Mar 20 '16