format long
n = 10; % number of c values to find
c = zeros(1,n);
delta = zeros(1,n-1);
c(1) = 0;
c(2) = -1;
delta(1) = 4;


for j = 2:(n-1)
    alpha_0 = c(j) + (c(j) - c(j-1))/delta(j-1); % initial guess for c
    c(j+1) = approximate(j, alpha_0);
    delta(j) = ((c(j)) - (c(j-1)))/((c(j+1))-(c(j)));
end
delta

function c_value = approximate(i, alpha_0)
    m = 50; % number of steps when approximating a c value
    alpha = alpha_0;
    for j = 1:m
        x = 0; xprime = 0;
        for k = 1:2^i
            xprime = 2*x*xprime + 1; 
            x = x^2 + alpha;
        end
        alpha = alpha - x/xprime;
    end
    c_value = alpha;
end
