MATLAB: Obtain eigenvalue from matrix and known eigenvector

eigenvalueeigenvectorMATLAB

I have a matrix A and a known eigenvector x. I am struggling to come up with an way of obtaining the eigenvalue of x with a relatively simple operation. One option is the following code:
A*x./x
However, this has problems when x contains any 0 entries. Is there any easy way of accomplishing this?

Best Answer

The simple answer, as long as the vector x IS an eigenvector. is just:
val = norm(A*x)/norm(x);
You should see that this is not a problem if x has some zero entries, as long as x is not the vector that is entirely zero.
If x is not an eigenvector, then of course it won't work, but we are told that x is an eigenvector so there is no problem. Ok, it does assume that the eigenvalue in question is real. If that is an issue, then a simple solution is still available. For example:
A = rand(5);
[V,D] = eig(A);
diag(D)
ans =
2.80100746971912 + 0i
0.396075677494192 + 0.0659443099214011i
0.396075677494192 - 0.0659443099214011i
-0.322864111476007 + 0i
-0.285307095833035 + 0i
Now, can we recover the first eigenvalue? It is real.
norm(A*V(:,1))/norm(V(:,1))
ans =
2.80100746971912
Of course, that will fail for the second eigenvalue. But only you know if the eigenvalues and eigenvectors are real in your problem.
Just pick the largest element in magnitude of the corresponding eigenvector.
V2 = V(:,2);
[~,ind] = max(abs(V2));
Av2 = A*V2;
val = Av2(ind)/V2(ind)
val =
0.396075677494192 + 0.0659443099214012i
Indeed, we have recovered the eigenvalue. Again, this is not a problem if the eigenvector has SOME zero elements, because I picked a specific element that is known to be non-zero.