Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question
1

Performing substitutions on powers of a variable

asked 9 years ago

Jernej gravatar image

updated 9 years ago

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 x21x43x2+x71x33x82+ would become 2x1x3x2+

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 9 years ago

tmonteil gravatar image

You should work modulo the ideal generated by the x2ixi:

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
Preview: (hide)
link

Comments

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

Jernej gravatar imageJernej ( 9 years ago )
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.

tmonteil gravatar imagetmonteil ( 9 years ago )

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 9 years ago

Seen: 400 times

Last updated: Mar 20 '16