1
$\begingroup$

I would like to report an issue which may be interesting in computational physics. Sometimes, to save time and memory, we use eigs() to calculate the first several eigenvalues of a sparse matrix. However, I find that the eigenvectors calculated in this way is not always accurate, especially only few eigenvalues are calculated, which may lead to severe problem for later calculation. Any comment, suggestion and solution to this issue is highly appreciated.

Please consider the matrix produced by this code (this code is irrelavent, just copy and use it)

%% generate the Hamiltonian matrix of the Ising model.
X = sparse([0,1;1,0]);
Z = sparse([1,0;0,-1]);
XX = kron(X,X);
L = 12;
h = 0;

Hamiltonian = -kron(kron(X,speye(2^(L-2))),X);
for i = 1:L-1
    Hamiltonian = Hamiltonian - kron(speye(2^(i-1)), kron(XX, speye(2^(L-1-i))));
end 
for i = 1:L
    Hamiltonian = Hamiltonian - kron(speye(2^(i-1)), kron(h*Z,speye(2^(L-i))));
end

I want to calculate the ground state energy, i.e. the minimal eigenvalue, and the corresponding eigenvector. To save time and memory, I use sparse matrix and eigs() to calculate the only first six eigenvalues and eigenvectors. Here is the code

%% calculate the first several eigenvalues and eigenvectors by eigs()
Hamiltonian = sparse(Hamiltonian);
[eigv, eigd]= eigs(Hamiltonian, 6, 'smallestreal');
[~, idx] = sort(diag(eigd));
vg = eigv(:,idx(1));
eg = eigd(idx(1));

After a long time check and verify, I finally find that, the minimal eigenvalue is well caculated (it's $-12$ in this case), but the corresponding eigenvector is not well caculated (it's elements are $0.0217, -0.0041, -0.0041 \cdots$ in this case). Then I tried two other methods. Firstly, I use eig() rather than eigs()

%% calculate the full eigenvalues and eigenvectors by eig()
Hamiltonian = full(Hamiltonian);
[eigv, eigd]= eig(Hamiltonian);
[~, idx] = sort(diag(eigd));
vg = eigv(:,idx(1));
eg = eigd(idx(1));

Secondly, I use eigs() but with a coverage of all the full eigenvalues

%% calculate the full eigenvalues and eigenvectors by eigs()
Hamiltonian = sparse(Hamiltonian);
[eigv, eigd]= eigs(Hamiltonian, length(Hamiltonian), 'smallestreal');
[~, idx] = sort(diag(eigd));
vg = eigv(:,idx(1));
eg = eigd(idx(1));

The results of the two methods are the same. For the minimal eigen value, it's $-12$. For the corresponding eigenvector, it's $0, 0.0221, 0.0221 \cdots$, which is different from the previous one, and we should belive this results is more accurate. Is there any comment on why eigs() is not that accurate when only several eigenvalues are included. And is there any suggestion that I can keep the eigs() accurate while ultilizing its superiority in time and memory saving?

$\endgroup$
2
  • 1
    $\begingroup$ What is your criteria for one eigenvector being more or less "well calculated" or "accurate" if they solve $Ax=\lambda x$? $\endgroup$
    – whpowell96
    Commented Mar 11 at 20:43
  • $\begingroup$ I tought the results of eig() is more accurate since it includes all the eigenvalues. However, accroding to the answer by @helloworld922, I finally find it's about the degeneracy. Thanks for your comment. $\endgroup$ Commented Mar 12 at 14:50

1 Answer 1

7
$\begingroup$

Eigenvectors are not unique, especially when you have repeat eigenvalues.

Let's define each unique eigenvalue as $\lambda_1$, $\lambda_2$, ..., $\lambda_i$, where $\lambda_i$ has a multiplicity of $n_i$. Then denote $v_i$ as an eigenvector corresponding to the eigenvalue $\lambda_i$.

I believe the only guarantees you get are:

  • If you take any eigenvectors from two distinct eigenvalues $v_i$ and $v_j$ for $i \neq j$ then $v_i \cdot v_j = 0$
  • The eigenspace formed by all possible choices of $v_i$ has dimension at most $n_i$. If $n_i = 1$, then we can at least narrow down $v_i$ to being different by just the sign (multiply by $\pm 1$, assuming that $\|v_i\| = 1$ which most implementations ensure). If $n_i > 1$, good luck.

For your particular matrix, the eigenvalue -12 is repeated twice so you could be getting different pairs of eigenvectors (all of which are valid) depending on the algorithm used. The only guarantee is that the eigenvectors you get will be orthogonal to the eigenvectors for other distinct eigenvalues, and you will find at most two linearly independent ones since the multiplicity of $\lambda_i=-12$ is two.

$\endgroup$
1
  • 1
    $\begingroup$ Thanks for your help. Indeed it's about degeneracy. I should have noticed that. $\endgroup$ Commented Mar 12 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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