Ask Your Question

Revision history [back]

If f is a symbolic function, you can get its Taylor expansion as follows:

sage: f = log((1-x)/(1-2*x))
sage: f.taylor(x,0,5)
31/5*x^5 + 15/4*x^4 + 7/3*x^3 + 3/2*x^2 + x

Then you can get its k^th coefficient as follows:

sage: f.taylor(x,0,5).coefficient(x^3)
7/3

If f is a symbolic function, you can get its Taylor expansion as follows:

sage: f = log((1-x)/(1-2*x))
sage: f.taylor(x,0,5)
31/5*x^5 + 15/4*x^4 + 7/3*x^3 + 3/2*x^2 + x

Then you can get its k^th coefficient as follows:

sage: f.taylor(x,0,5).coefficient(x^3)
7/3

Or:

sage: f.taylor(x,0,5).coefficients()
[[1, 1], [3/2, 2], [7/3, 3], [15/4, 4], [31/5, 5]]
sage: f.taylor(x,0,5).list()
[0, 1, 3/2, 7/3, 15/4, 31/5]