# 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

How to get a polynomial by changing base

0

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 +0200 **

Seen: **80 times**

Last updated: **Mar 07 '22**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.

Welcome to Ask Sage! Thank you for your question.