Eigenvectors and eigenvalues

Syntax: y = EIGEN(m)

If matrix m is an n by n symmetric matrix, then EIGEN(m) returns a matrix with n rows and n+1 columns. Column n+1 contains the eigenvalues, while columns 1 through n are the eigenvectors of the symmetric matrix m. The eigenvector x and the eigenvalue s of matrix m satisfy the equation:    m<>x = s*x.

One way to check a result is with the following script:

   e=EIGEN(m)
   n=vlen(m)[1]
   DO j = [1:n]
     =m<>e[*,j]-e[j,n+1]*e[*,j] ! these should be all zero (or close to zero)
   ENDDO
 

Example

The following commands:

   m=[[2;-1;0;0];[-1;2;-1;0];[0;-1;2;-1];[0;0;-1;2]]
   e=eigen(m)
 

produces:

   matrix m
        2    -1    0    0
       -1     2   -1    0
        0    -1    2   -1
        0     0   -1    2
   matrix e
     0.371748  0.601501  0.601501 -0.371748  0.381966
     0.601501  0.371748 -0.371748  0.601501  1.38197
     0.601501 -0.371748 -0.371748 -0.601501  2.61803
     0.371748 -0.601501  0.601501  0.371748  3.61803
 

The eigenvalues are e[*,5] = [0.381966;1.38197;2.61803;3.61803]

The four eigenvectors are e[*,j] for j=[1:4]