How to get a polynomial by changing base
I want to have (x-3)^2 as a polynomial in (x-1) as opposed to x; I want it output (x-1)^2 - 4(x-1) + 4
I want to have (x-3)^2 as a polynomial in (x-1) as opposed to x; I want it output (x-1)^2 - 4(x-1) + 4
Symbolic expressions have a taylor
method which is supposed to do that.
Below, f.taylor(x, 1, 2)
does a Taylor expansion of f
with respect to x
at the point 1
to the order 2
.
Unfortunately it does not keep the linear term in the desired form:
sage: f = (x - 3)^2
sage: f.taylor(x, 1, 2)
(x - 1)^2 - 4*x + 8
There was already a Sage Trac ticket about that:
which was closed because the initial formulation of the ticket was that the result was incorrect; in fact the result is correct but the way it is displayed is incorrect, so I reopened that ticket.
Workaround
In your case, if you want to get the coefficients that should go
in front of the various powers of (x - 1)
, you can shift f
by 1
:
sage: x = polygen(QQ)
sage: f = (x - 3)^2
sage: f(x + 1)
x^2 - 4*x + 4
This tells you f
is (x -1)^2 - 4*(x - 1) + 4
.
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 2022-03-07 12:01:15 +0100
Seen: 150 times
Last updated: Mar 07 '22
Welcome to Ask Sage! Thank you for your question.