Ask Your Question
0

Shift polynomials

asked 2018-07-14 17:27:35 +0200

philipp7 gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-07-14 18:20:00 +0200

tmonteil gravatar image

You can do:

sage: p(x+2)
5*x^2 + 17*x + 15

sage: p(x+2) in R
True

Actually, the following works too:

sage: p.subs(x=x+2)
5*x^2 + 17*x + 15
edit flag offensive delete link more

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: 2018-07-14 17:27:35 +0200

Seen: 434 times

Last updated: Jul 14 '18