function [ind,x,relres] = maxdescenso(A,b,tol,maxit)
x = zeros(length(b),1);
r = b;
it = 1;
while (it <= maxit) && (norm(r)/norm(b) > tol)
   d = r;
   l = (d'*r)/(d'*(A*d));
   x = x + l*d;
   r = r - l*(A*d);
   it = it + 1;
end
relres = norm(r)/norm(b);
if (norm(r)/norm(b) <= tol)
    ind = 1;
else
    ind = 0;
end

