I would appreciate any comments on the following:
/* This code implements the first method as described in the paper by
Henri Cohen, Fernando Rodriguez Villegas and Don Zagier:
Convergence Acceleration of Alternating Series.
It has the same name as the Pari function.
It is LGPL'd and copyright assigned to the FSF.
Dan Stanger (dan.stanger@ieee.org) 4/6/03
It computes sum(-1^k*a[k],k,0,inf)
Arguments:
a A array of the terms,
n The number of elements to use.
A simple example:
array(f,8);
fillarray(f,[1,1/2,1/3,1/4,1/5,1/6,1/7,1/8,1/9]);
sumalt(f,9)-ln(2.0d0);
*/
sumalt(a,n):=block([d:dfloat((1/2)*(((3+sqrt(8))^n)+1/((3+sqrt(8))^n))),
b:-1.0d0,c,s:0.0d0],
c:-d,
for k:0 thru (n-1) do (
c:b-c,
s:s+c*a[k],
b:dfloat(k+n)*dfloat(k-n)*b/((dfloat(k)+0.5d0)*dfloat(k+1))),
s/d
)$