function mg(k,nu1,nu2,mu,u,ur)

%   Multigrid mu-cycle

%   Relax nu1 times (pre-relaxations sweeps).

for i = 1:nu1
    relax(k)
end

%   If k ~= 1 continue down to next-coarser grid.

if k > 1
    
    %   Restrict residuals and form right-hand sides on next coarser grid.

    restrict(k,k-1)
    
    %   Perform mu multigrid cycles.

    for i = 1:mu
        mg(k-1,nu1,nu2,mu,u,ur)
    end
    
    %   Interpolate and add the correction to the solution on next-finer grid.

    intadd(k,k-1)
end

%   Relax nu2 times (post-relaxations sweeps).

for i = 1:nu2
    relax(k)
end
