function s=EpsilonAlgorithm(x);
% EPSILONALGORITHMLOWSTORAGE epsilon algorithm with low storage
%   s=EpsilonAlgorithm(x) is an implementation of the
%   epsilon algorithm of P. Wynn using only litte storage. x contains the
%   elements of a sequence whose convergence we want to accelerate, and s
%   is the last element of the accelerated sequence.

k = floor((length(x)-1)/2);
e(1)=x(1);
for i=2:2*k+1
  v=0; e(i)=x(i); 
  for j=i:-1:2
    d=e(j)-e(j-1); w=v+1/d; 
    v=e(j-1); e(j-1)=w;
  end;
  W(i-1)=w;
end
s = e(1);