Follow-up: I think I have found a way that works. I guess if one is interested in expanding about 0, one can simply do >>> f = x + 5 * x**3 >>> coeffs = reversed(series(f, x, 0, n = 4).as_poly(x).all_coeffs()) >>> list(coeffs) [0, 1, 0, 5]
So, to expand about x0!= 0, I can substitute x->x0 + x1 and expand in orders of x1. If this is a bad way to do it, please let me know! Thanks, Nikolas On Thursday, September 13, 2012 9:42:30 AM UTC+9, nikolas wrote: > > Hey guys, > > for a series expansion of some function f(x) about some point x0 up to > order n+1, I would like to easily generate the sequence of all coefficients. > I.e. if we have > > f(x) = a0 + a1 * (x-x0) + a2 * (x-x0)**2 + ... + an (x-x0)**n + > O((x-x0)**n) > > is there a straightforward way to obtain a generator for the sequence a0, > a1, a2, ... an that includes the non-zero terms? > With the current implementation of series, I get: > > >>> f = x + 5 * x**3 > >>> coeffs = series(f, x, 0, n = None) > >>> for c in coeffs: > >>> print str(c) + ", ", > x, 5 * x**3, > > It would be nice to add a flag, e.g. include_nozero=True such that > >>> f = x + 5 * x**3 > >>> coeffs = series(f, x, 0, n = None) > >>> for c in coeffs: > >>> print str(c) + " + ", > 0, x, 0, 5 * x**3, > > Then I could simply divide each term by (x-x0)**k to get the actual > coefficient... > Is there some other way to achieve this functionality easily? It would > seem that under the hood the machinery to do all this would already be in > place... > Thanks! > > Nikolas > > > > -- You received this message because you are subscribed to the Google Groups "sympy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sympy/-/VYpSrjmMFdgJ. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.