In Mathematica, I can do expression replacement like x^2 -> x which changes power 2 of x into x. I wonder if there are any similar functionalities in sage?
R = PolynomialRing(ZZ, 2, "a") a = R.gens() (a + a)^2 Out: a0^2 + 2*a0*a1 + a1^2
I would like to change all powers of a (> 1) into power 1. So replace a^k -> a for k >= 1.
So the desire output would be a0 + 2*a0*a1 + a1