function alpha_k=wolfe(Xk,f,pk,df)

alpha_0=1;
c1=1e-4;
c2=0.9;
alphatol=1e-6;

temp=Xk+alpha_0*pk;   % temp=xk+alpha_k*pk
pt2=temp(1,1);
pt3=temp(2,1);
pr2=temp(3,1);
pr3=temp(4,1);

temp_fk=eval(f);    % f(xk+alpha_k*pk)

pt=Xk(1,1);
pr=Xk(2,1);


fk=eval(f);
gk=eval(df);

ii=1;                    % to count iterates for wolf condition
iiMax=50;                % maximum iterates for wolf condition
alpha_k=alpha_0;


while (ii<=iiMax)
    while (temp_fk>fk+c1*alpha_k*gk'*pk && alpha_k>alphatol)   % wolf condition 1
        temp=Xk+alpha_k*pk;           % update temp
        pt2=temp(1,1);
        pt3=temp(2,1);
        pr2=temp(3,1);
        pr3=temp(4,1);
       
        
        temp_fk=eval(f);         % update temp_fk
        
        alpha_k=alpha_k/2;
    end
    temp_gk=eval(df);        % delta f(xk+alpha_k*pk)
   
    if temp_gk'*pk<c2*gk'*pk   % wolf condition 2
        alpha_k=alpha_k*1.5;
    else
        break;
    end
    ii=ii+1;         % update iterate count for wolf condition
end

