[Newbie] expansion of a function as a power series



On 7/25/07, Hugo Coolens <coolens at kahosl.be> wrote:
> Can anyone tell me how to "harvest" the coefficient of x^n in the
> expansion of the function x/(1-x-x?^2) as a ower series around the origin?

expr: x/(1-x-x^2)$

ser: taylor(expr,x,0,10)$

ratcoeff(ser,x,2) gives you the coefficient of x^2.  This is more
reliable than "part", which simply counts terms from the beginning.
If there is more than one term in the constant part, or terms with 0
coefficients, "part" won't get the right answer.  For example,

      part(taylor(cos(x),x,0,10),3)/x^3 => x/24 (wrong)
but
      ratcoeff(taylor(cos(x),x,10),x,3) => 0 (correct)

            -s