clear all
clc

re_freq = 50; % the restart frequency used

% Test Nesterov coefficients for type III
theta = 1;
for count = 1:6
    theta = 2/(1 + sqrt(1+4/theta^2));     
end
gamma = 0.95;
test0 = 1;
iter = 1;
while iter <= re_freq;
    thetaold = theta;
    theta = 2/(1 + sqrt(1+4/theta^2));
    test0 = test0 && theta^2*(1-thetaold)^2/gamma-thetaold^2<0 && theta^2/(1-gamma)-1<0;
    iter = iter + 1;
end
thetaold = theta;
test0 = test0 && theta^2*(1-thetaold)^2/gamma-thetaold^2<0 && theta^2/(1-gamma)-1<0;

% Test Nesterov coefficients for type II

fprintf(' *************** \n')
theta = zeros(2*re_freq,1); % generate a theta vector
theta(1) = 1;
count = 1;
while count < 2*re_freq
    if  count <= re_freq - 1
        theta(count+1) = 2/(1 + sqrt(1 + 4/theta(count)^2));
    elseif count >= re_freq + 1
        theta(count+1) = theta(count)/sqrt(1 - theta(count)); % inverse of the formula above
    else
        theta(count+1) = theta(count);
    end
    count = count + 1;
end

test = 1;
for count = 1:2*re_freq-1
    test = test && theta(count+1)^2*(1-theta(count))^2-theta(count)^2<0;
end

    
    
    
    

 