sum(1) = 1;
z = .99;
a = zeros(1500,1);
sum = zeros(1500,1);
Ssum = zeros(42,1);
SSsum = zeros(16,1);
az = 1;
a(1) = .5;
sum(1) = .5;
format long
sumex = 1/((1+z)*(z+2));
b = .25;
for i = 2:1500 
    az   = - z*az;
    a(i) = az*(1-b);
    sum(i) = sum(i-1) + a(i);
    b = b/2;
end
sum-sumex;
for i = 1:42
    Ssum(i) = (sum(i+2)*sum(i)-sum(i+1)^2)/(sum(i+2)+sum(i)-2*sum(i+1));
end
Ssum-sumex
for i = 1:16
    SSsum(i) = (Ssum(i+2)*Ssum(i)-Ssum(i+1)^2)/(Ssum(i+2)+Ssum(i)-2*Ssum(i+1));
end
SSsum - sumex
