Ralf Stephan on Sat, 16 Aug 2014 08:04:21 +0200


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

Re: Vec() and leading zeros of generating function


Convert into polynomial first:
? s=x^2 + x^4 + O(x^11)
%8 = x^2 + x^4 + O(x^11)
? Vec(Pol(s))
%9 = [1, 0, 1, 0, 0]

Now just reverse.

On Sat, Aug 16, 2014 at 7:43 AM, Kevin Ryde <user42_kevin@yahoo.com.au> wrote:
> 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.
>