function [u,k] = multigrid_iter(L,A,b,prec)

n = length(b);
u = zeros(n,1);
r = b-A*u;
norm0 = norm(r);

k = 0;

while norm(r)/norm0 > prec
    u = u + multigrid(L,r);
    r = b-A*u;
    k = k+1;
end
