Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Shift polynomials

Say we have a polynomial over the rationals:

R.<x> = PolynomialRing(QQ)
p = 5*x^2-3*x+1

I want to shift this polynomial by an integer, i.e. I want to do something like (note that the shift function already exists but it does something different)

p.shift(2)  # should give the polynomial 5*(x+2)^2-3*(x+2)+1 in R

This seems to be quite a simple thing. However, I cannot figure out how to do this. I tried to use substitute (p.subs(x=x+2)), but it did not work. One way it might work is to consider the polynomial in the symbolic ring, substitute there and convert it back to the polynomial ring. This seems too complicated for this small problem.

Does anyone have an idea how this could be done conveniently?

Thank you very much for your help!