Kevin Ryde on Sat, 16 Aug 2014 07:47:12 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Vec() and leading zeros of generating function


Vec() can give terms from a polynomial generating function but it
doesn't include leading zeros.  Eg.

    Vec(x^2/(1-2*x) + O(x^5))
    =>
    [1, 2, 4]

Is there a good way to start from the zero'th term so I would get

    [0, 0, 1, 2, 4]

I have to confess to only doing this by cut-and-paste programming, so
perhaps there's something completely different I don't know which is
better. :-) My main use has been to compare against expected or desired
values, so

    want = [1, -1, 1, -1]
    Vec(1/(1+x) + O(x^length(want))) == want || error("oops")

I see some Pol(Vecrev()) can turn the values into a poly for the
compare, but poly -> values helps for printing the values too.