Search code examples
matlabeigenvectoreigenvalue

Finding the Associated Eigenvector in Matlab


For this problem, I think I got most of code correct. However, the correct eigenvector contains the negative values of what I have.

The instructions:

enter image description here

My code:

clear all; close all;

M = [0 1/4 1/4 0 0 0 0 0 0 0;
   1/2 0 1/4 1/4 1/6 0 0 0 0 0; 
   1/2 1/4 0 0 1/6 1/4 0 0 0 0; 
   0 1/4 0 0 1/6 0 1/2 1/4 0 0; 
   0 1/4 1/4 1/4 0 1/4 0 1/4 1/4 0; 
   0 0 1/4 0 1/6 0 0 0 1/4 1/2; 
   0 0 0 1/4 0 0 0 1/4 0 0; 
   0 0 0 1/4 1/6 0 1/2 0 1/4 0; 
   0 0 0 0 1/6 1/4 0 1/4 0 1/2; 
   0 0 0 0 0 1/4 0 0 1/4 0];

[Y, Z] = eig(M) % pull the first column of T

A8 = Y(:,1) % P

M*A8 % check

save ('A8.dat', 'A8', '-ascii')

I use,

[Y, Z] = eig(M)

to find the associated eigenvalue of 1 in Z with its associated eigenvector from Y. This yields P (or A8) to be:

0.1667
0.3333
0.3333
0.3333
0.5000
0.3333
0.1667
0.3333
0.3333
0.1667

And when I multiply M by P, I get P, which checks out. Apparently the proper values should be negative values of what I got. Can someone clarify?


Solution

  • This behaviour is correct. To understand the reason, we need to look at the definition of eigenvectors (source: wikipedia):

    An eigenvector or characteristic vector of a square matrix A is a non-zero vector v that, when multiplied with A, yields a scalar multiple of itself. [...] That is: Av = nv.

    where v is the eigenvector and n is the corresponding eigenvalue.

    As these are linear operations, A*(kv)=n*(kv) for any non-zero, scalar k. That means, an eigenvector multiplied by a factor k will be another eigenvector to the corresponding eigenvalue.

    Matlab outputs normalized eigenvectors, i.e. their length (norm(A8)) equals 1. But still, both the positive and the negative version are eigenvectors of M. You can verify this by creating the negative version of your result and multiplying it with P, which will again give you the negative version of your result.