Ask Your Question

Revision history [back]

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

Either open a ticket on the Sage Trac server about that, or I will do it.

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

Either open There was already a ticket on the Sage Trac server ticket about that, or I will do it.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.

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.