MATLAB: Need help for cross checking of eigen Vector

eigen

I have a matrix
A=[2 1 1;2 3 2;1 1 2]
I have calculated its eigen values and associated eigen vectors by hand. I have cross checked the eigen values by using command eig(A). My eigen values are correct.
But how can i cross check that my manual calculation of Eigen Vectors is correct.
I have got eigen vector [1;2;1] for eigen value=5 I have got eigen vector [-2;1;1] for eigen value=1
Plz tell me the method to cross check eigen vectors

Best Answer

This gives a possible set of unit eigenvectors.
[V,D] = eig(A)
If there is an eigenspace of more than one dimension, the vectors in V are not unique. Note also, that since the vectors in V are unit vectors, you need to normalize your vector in order to compare.
From the command above, we can see that the first and third columns of V correspond with the eigenvalue 1, and the second column of V corresponds with the eigenvalue 5. Normalizing [1; 2; 1] and taking the difference with V(:,2) yields the following.
V(:,2) - [1; 2; 1] ./ norm([1; 2; 1])
ans =
1.66533453693773e-016
-2.22044604925031e-016
0
Since the difference is on the order of machine epsilon (this can be checked with eps(V(1,2)) and eps(V(2,2))), we can say that to within machine precision Matlab's answer agrees with your answer for this eigenvalue.
It is possible that your eigenvector for the eigenvalue 1 is in the same eigenspace as given by columns one and three of V. To test this do the following.
coeffs = V(:,[1 3]) \ [-2; 1; 1];
coeffs(1)*V(:,1) + coeffs(2)*V(:,3)
Since the result is the vector [-2; 1; 1], we know that your eigenvector is in the eigenspace determined by the span of V(:,1) and V(:,3). Thus, your eigenvector for eigenvalue 1 is correct.
All of this has been fun (for me at least), but there is a much more direct method of testing an eigenpair for correctness.
>> A * [-2; 1; 1]
ans =
-2
1
1
>> A * [1; 2; 1]
ans =
5
10
5
This shows, directly, that your answers are correct.