MATLAB: How to specify one eigenvector then find the rest.

eigeigenvalueeigenvectoreigs

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

Best Answer

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.