function [u,k] = steepest_descent(A,b,u0,prec)

u = u0;
r = b - A*u;
k = 0;
normk = norm(r);
initNorm = normk;

while normk/initNorm > prec
    alpha = (r'*r)/(r'*A*r);
    u = u + alpha*r;
    r = b - A*u;
    normk = norm(r);
    k = k+1;
end