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.