function [ uk, lambdak ] = RQIteration( w0, A, mu )
%RQIteration Approximate eigenvector and eigenvalue of A
%   Input: w0 = initial guess, A = matrix (it should be symmetric),
%          mu = any number that is not eigenvalue of A
%   Output: approximated eigenvector and eigenvalue

format long

NumIter = 10;

n = size(A,1);
B = A - mu*eye(n);

utemp = w0/norm(w0);
for r=1:NumIter
    wk = B\utemp;
    uk = wk/norm(wk)
    rk = uk'*(B\uk);
    lambdak = 1/rk+mu
    utemp = uk;
    yn = input('Input 0 to stop. Press enter to continue: ');
    if yn == 0
        break;
    end
end

end