Azzera filtri
Azzera filtri

How to specify one eigenvector then find the rest.

4 visualizzazioni (ultimi 30 giorni)
Hi, I need to find the eigenvalues and eigenvectors for a square, positive semidefinite matrix where zero is an eigenvalue with geometric multiplicity > 1. I want the first eigenvector to always be the ones vector. Is there a way to do this with the eig or eigs function in MATLAB? If not, does anyone have suggestions on another way?
Here is an example, you can see the ones vector is an eigenvector associated with a zero eigenvalue, but it is not the one MATLAB chooses. Is there a way to force this?
>> G=[2 -1 -1 0 0; -1 2 -1 0 0; -1 -1 3 0 -1; 0 0 0 0 0; 0 0 -1 0 1]
>> [v d]=eig(G)
v =
-0.2206 -0.4487 -0.4082 0.7071 0.2887
-0.2206 -0.4487 -0.4082 -0.7071 0.2887
-0.2206 -0.4487 -0.0000 -0.0000 -0.8660
0.8974 -0.4411 -0.0000 0.0000 0
-0.2206 -0.4487 0.8165 0.0000 0.2887
d =
-0.0000 0 0 0 0
0 0.0000 0 0 0
0 0 1.0000 0 0
0 0 0 3.0000 0
0 0 0 0 4.0000
>> G*ones(5,1)
ans =
0
0
0
0
0

Risposta accettata

John D'Errico
John D'Errico il 24 Gen 2019
Sorry, but no. You cannot just decide that the vector of all ones is an eigenvector. An eigenvector has a very specific property for a given matrix. And the eigenvectors are different for different matrices. For example, to pick a random matrix...
A = rand(5,5);
A*ones(5,1)
ans =
2.3078
2.8566
2.3404
1.7379
3.5337
For that matrix, nothing in this universe can make the vector of ones be an eigenvector.
In SOME cases, you may succeed in your quest, but only when the vector of ones lies in the subspace spanned by eigenvectors with a repeated eigenvalue. Then you could rotate the eigenvectors to be as you wish. But in fact, that goal is probably an unlikely event. And in fact, even IF the constant vector happens to be an eigenvector, it won't be normalized as you seem to wish. It would be normalized as ones(5,1)/sqrt(5).
So let me look at your matrix.
G=[2 -1 -1 0 0; -1 2 -1 0 0; -1 -1 3 0 -1; 0 0 0 0 0; 0 0 -1 0 1];
[V,D] = eig(G)
V =
-0.22056 -0.44872 -0.40825 0.70711 0.28868
-0.22056 -0.44872 -0.40825 -0.70711 0.28868
-0.22056 -0.44872 -1.1795e-16 -4.9304e-32 -0.86603
0.89745 -0.44112 -1.1102e-16 2.7756e-16 0
-0.22056 -0.44872 0.8165 7.7528e-33 0.28868
D =
-5.457e-17 0 0 0 0
0 2.2587e-16 0 0 0
0 0 1 0 0
0 0 0 3 0
0 0 0 0 4
So you have one repeated eigenvalue at zero. Eig does not happen to have your choice for an eigenvector as one of them. But is ones(5,1) a valid eigenvector?
G*ones(5,1)
ans =
0
0
0
0
0
So that vector does indeed lie in the nullspace of G. This means there is some linear combination of the first two eigenvectors that will yield a vector of ones. We can find it simply enough as:
coef = V(:,1:2)'*ones(5,1)
coef =
0.015215
-2.236
coef(1)*V(:,1) + coef(2)*V(:,2)
ans =
1
1
1
1
1
Again however, this vector is not what eig would ever return, since it is not a unit vector. But we can easily enough rotate that pair of eigenvectors. This works as long as we know that the contstant vector is actually in the nullspace of G.
V(:,1:2) = V(:,1:2)*[coef,null(coef')]
V =
1 -0.22361 -0.40825 0.70711 0.28868
1 -0.22361 -0.40825 -0.70711 0.28868
1 -0.22361 -1.1795e-16 -4.9304e-32 -0.86603
1 0.89443 -1.1102e-16 2.7756e-16 0
1 -0.22361 0.8165 7.7528e-33 0.28868
You can see that the new V is still a valid set of eigenvectors, even though that first vector is scaled inconsistently.
G*V - V*D
ans =
7.207e-16 2.7255e-16 2.2204e-16 0 2.2204e-16
5.457e-17 -6.0515e-17 2.2204e-16 0 2.2204e-16
-1.0557e-15 -5.0042e-18 -1.0409e-16 1.1102e-16 -4.4409e-16
5.457e-17 -2.0203e-16 1.1102e-16 -8.3267e-16 0
2.7661e-16 -5.0042e-18 -1.1102e-16 3.3798e-32 2.2204e-16
Why you want to do this, I have no idea. But people want to do strange things all the time.
  3 Commenti
John D'Errico
John D'Errico il 24 Gen 2019
Not sure why it would it be widely used. It is almost never true in my work that one KNOWS one of the eigenvectors in advance. I can think of examples where one knows an eigenvalue - that is rather common. But I might strain to think of a case where I have known an eigenvector in advance.
Anyway, the rotation I show is simple enough that you can get what you want.
Andrew Knyazev
Andrew Knyazev il 5 Giu 2020
Modificato: Andrew Knyazev il 5 Giu 2020
It is possible in https://www.mathworks.com/matlabcentral/fileexchange/48-locally-optimal-block-preconditioned-conjugate-gradient (which is used in Python scikit-learn for symmetric graph Laplacians in spectral clustering) to compute eigenvectors in an orthogonal complement to any given subspace still not touching the original matrices, but it might not actually give any performance improvement in your scenario.
A better idea in terms of performance is to include the eigenvector that is already known as one of the initial vectors, which is also possible in https://www.mathworks.com/matlabcentral/fileexchange/48-locally-optimal-block-preconditioned-conjugate-gradient
Neither of these options is available in eigs.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by