function [y, V] = scalar_epsilon(x) %Implementation of the scalar-epsilon algorithm %Wynn, MTAC, 10 (1956) pp. 91-96 % % x: vector that holds the sequence to be accelarated % y: approximate accelarated limit % V: Sequence matrix of limits % %CAUTION: This is not a memory friendly implementation! %C. Bekas, CS Dept. University of Minnesota, Dec. 2004 %Allocate memory n = length(x); V = zeros(n,n+1); %First column is zero, second column is equal to x V(:,2) = x; index = 0; %Main iteration for k=3:n+2 index = index+1; for i = 1 : n - index V(i,k) = V(i+1,k-2) + 1/(V(i+1,k-1) - V(i,k-1)); end end if (rem(n,2) == 0) y = V(2,end-1); else y = V(1,end); end