Loading [MathJax]/jax/output/HTML-CSS/jax.js

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

asked 9 years ago

Jernej gravatar image

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 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?

click to hide/show revision 2
No.2 Revision

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 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?

click to hide/show revision 3
No.3 Revision

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 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.