I'm trying find the eigenvalues of a matrix A using QR iteration with Householder. I used this code which I found from Cornell University that decomposes QR with Householder.
A= [3.56829648331616, -2.19026841424281,0.557474633283884,-0.126072015319561; -3.25393787896303, 4.81285873937612,-2.79568990543933,0.632240894103258 1.14081451177546, -4.13904528762030, 6.19190034744431,-2.98172499459682 -0.639981731971678, 2.32194922534595, -7.91889162828103,6.11802605281534] [m,n] = size(A); Q = eye(m); % Orthogonal transform so far R = A; % Transformed matrix so far for j = 1:n % -- Find H = I-tau*w*w’ to put zeros below R(j,j) normx = norm(R(j:end,j)); s = -sign(R(j,j)); u1 = R(j,j) - s*normx; w = R(j:end,j)/u1; w(1) = 1; tau = -s*u1/normx; % -- R := HR, Q := QH R(j:end,:) = R(j:end,:)-(tau*w)*(w'*R(j:end,:)); Q(:,j:end) = Q(:,j:end)-(Q(:,j:end)*w)*(tau*w)'; end
Now that I have the correct R and Q verified through MATLAB, I should be able to find the eigenvalues by multiplying R and Q.
where the diagonal elements of E must contain the eigenvalues and is symmetric.
However, upon doing so its not giving me the correct eigenvalues.
Do I have to write another iteration to find the eigenvalues with Q and R?