1
$\begingroup$

I'm using Jacobi iterative method for finding eigenvalue and eigenvector for hermitian or symmetric matrix. Eigenvectors corresponding to eigenvalues are not exact. The third eigenvector is totally off. That I've implemented and read about Jacobi. What are the possible reasons for that?

This is my function file in scilab:

function [eig,eigv]=Jacobimethod(A, I)
r=0
while [1]

B=A-diag(diag(A)) 
[m, index]=max(abs(B))
if m==0
   break
end

p=min(index)
q=max(index)
R=eye(n,n)
if A(p,p)==A(q,q)
   theta=%pi/4
   else
theta=(atan(2*A(p,q)/(A(p,p)-A(q,q))))/2
end
c=cos(theta)
s=sin(theta)
R(p,p)=c
R(q,q)=c
R(p,q)=-s
R(q,p)=s
Anew=clean((R')*A*R,10^-4)
//disp(Anew)
   eig=diag(Anew)
   A=Anew 
   X=I*R
   eigv=X
   I=X 
 r=r+1
 
end 
disp(r,"No of iterations")     
endfunction
$\endgroup$
1
$\begingroup$

Probably you accumulated rotations wrong. At each step, you have a working matrix $D$ that starts from $D=A$ and should converge to a diagonal matrix, and a matrix $Q$ that accumulates all rotations performed on $D$. Print after each step $\|QDQ^T - A\|$, and see where it stops being small.

$\endgroup$
2
  • $\begingroup$ No, I have taken right rotations. I have taken this as precaution. Eigenvalues are correct upto 4 decimals but not eigenvectors of same matrix. $\endgroup$
    – S0s
    Sep 27 '20 at 19:09
  • $\begingroup$ Anyway, if you can verify that you have found a diagonal (up to machine precision) matrix $D$ and an orthogonal matrix $Q$ such that $\|QDQ^T-A\| / \|A\|$ is of the order of machine precision, then you have successfully solved your problem; there is no possibility that the eigenvectors are wrong, because that is the definition of a (backward stable) solution. Maybe your $D$ is not "diagonal enough" for you to stop? $\endgroup$ Sep 27 '20 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.