So for a rational function one could do this to get the series approximation?
def rseries(p, x, o):
"""Return truncated series of univariate rational p in
variables x up to order o about the point x = 0.
"""
n, d = p.as_numer_denom()
if not all(i.is_polynomial() for i in (n, d)):
return
def rp(p):
rv = 0
for a in Add.make_args(p.expand()):
c, b = a.as_coeff_Mul()
if b == 1:
e = 0
else:
e = b.as_base_exp()[1]
rv += c*r**e
return rv
n, d = map(rp, (n, d))
return rs_mul(n, rs_series_inversion(d, r, o), r, o)
>>> x = var('x')
>>> rseries(x/(1-x+x**2+3*x**10),x,12)
-4*x**11 - x**10 + x**8 + x**7 - x**5 - x**4 + x**2 + x
>>> _.as_expr().coeff(x**11)
-4
Given that this is so much faster, I wonder why this is not implemented for series.Perhaps that is
part of the work that can yet be done on series: using input type to tailor that method used
to give the output.
BTW, this runs for Anane's expression without timing out on
live.sympy.org.
/c