%
%
%
function [m,P_] = calc_m(rk,w_,a1,a2)
[w,P_] = eValP(rk,a1,a2);
if norm(w-w_,1)<10^-3
    m = rk+1;
else
    i = 1;
    done = 0;
    while 1
        [w,P_] = eValP(rk+i,a1,a2);
        if interlacing_cond(w_,w,rk+i+1)
            done = 1;
        else
            i = i+1;
        end
        if done
            break;
        end 
    end
    m = rk+1+i;
end