expanding sums



Pol,


The command
>  sum(f[n](1/4),n,0,4);
> seems of no use, since only the final result is returned.
>
> The only way i know is through a for-loop
>  for n: 0 thru 4 do disp(f[n](x));
> listing terms in a column.
>
> Any possibility to display the terms on one line?


Better yet, why not return the data in a list so you can use it later.
Perhaps this will do:

(%i59) block([ret:[]], for n:0 thru 4 do ret:cons(f[n](x), ret),
reverse(ret));

(%o59) [1,x,x^2/2,x^3/6,x^4/24]

(%i60)  %,x=1/4;
(%o60) [1,1/4,1/32,1/384,1/6144]

(%i61) apply("+", %);
(%o61) 7889/6144

(please excuse the Lisp like idiom)

Zach