function [YNew,counter,residual] = IMPLICIT(y,h,tolerance) 
% 
% k1 = fixed_point(y,h);
% 
y_k = y;

error = 5;
counter = 0;

%% Explicit Predictor using Kutta's Method

% k1 = fun(y);
% k2 = fun(y + (7/9)*(h.* k1));
% k3 = fun(y + ((364437/9856)*(h.* k1))+((-359509/9856)*(h.* k2)));
% k4 = fun(y + ((37/154)*(h.* k1))+((1/2)*(h.* k2))+((20/77)*(h.* k3)));
% k5 = fun(y + ((-107/90)*(h.* k1))+((4/5)*(h.* k2))+((4/9)*(h.* k3)))+((1/2)*(h.* k4));
% y_k = y + ((1/20).*h.*k1)+((1/50).*h.*k2)+((8/225).*h.*k3)+((-49/720).*h.*k4)+((77/80).*h.*k5);

%% Implicit Corrector Step
counter = 0;
while error >= tolerance
    y_2 = y + ((1)*(h.*fun(((1/2).*y)+((1/2).*y_k))));
    if counter == 0
        residual = norm(y_2-y_k);
    end
    error_vector = abs(y_2-y_k);
    error = norm(error_vector);
    counter = counter + 1;
    y_k = y_2;
end

YNew = y_2;
    
  