function x=gradiens2D(A,b,k)

xregi=[0;0];
r=b;
% Ábra
x1=linspace(-1,5);
y1=x1;
[x2, y2]=meshgrid(x1,y1);
z=1/2*(A(1,1)*x2.^2+2*A(1,2)*x2.*y2+A(2,2)*y2.^2)-b(1)*x2-b(2)*y2;
figure(1)
mesh(x1,y1,z)
%
hold on
for i=1:k
    alfa=(r'*r)/(r'*A*r);
    xuj=xregi+alfa*r;
    r=b-A*xuj;
    %figure(1)
    %plot(i,norm(r),'b+'); % nem monoton!
    %figure(2)
    figure(2)
    plot([xregi(1),xuj(1)],[xregi(2),xuj(2)],'r');
    figure(1)
    
    xregi=xuj;
end



