function fmg(k,nu1,nu2,nu0,mu,u,ur)

%   Multigrid mu-cycle full approximation scheme.

%   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 the solution to next-coarser grid.

    put(k,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
        fmg(k-1,nu1,nu2,nu0,mu,u,ur)
    end
    
    %   Subtract the solution of the next-finer grid from the current
    %   solution, to obtain the correction.

    subtract(k,k-1)
      
    %   Interpolate and add the correction to the solution on next-finer grid.

    intadd(k,k-1)
end

%   Relax nu2 times (post-relaxations sweeps).

if k == 1
    for i = 1:nu0
        relax(k)
    end
else
    for i = 1:nu2
        relax(k)
    end
end