Eigenvalues & Eigenvectors (NumPy)
Definition
Let
Rewriting this equation, we see that
where
Here are three examples that we will consider. In each case, we have pre-computed the eigenvalues and eigenvectors (check them yourself).
Notice, for matrix
Warning
Eigenvectors are not unique, any scalar multiple of an eigenvector is an eigenvector. Therefore, some caution is needed when having SciPy compute eigenvectors. The values returned will be in floating point form, if you expected an eigenvector with integer or rational number entries you may need to rescale it to get it into this form. We'll see examples of this below.
scipy.linalg.eig
The function scipy.linalg.eig
computes eigenvalues and eigenvectors of a square matrix
Example
Determine the eigenvalues and eigenvectors of
The eigenvalues are
To check this directly in python we can use the tuple assignment to capture the arrays for eigenvalues and eigenvectors, and then pick off the two vectors.
Example
Determine the eigenvalues and eigenvectors of
Example
Determine the eigenvalues and eigenvectors of
(array([-3.+0.j, 4.+0.j, 2.+0.j]),
array([[ 5.77350269e-01, -8.33283831e-16, -7.07106781e-01],
[ 5.77350269e-01, -7.07106781e-01, -7.07106781e-01],
[ 5.77350269e-01, -7.07106781e-01, 3.33066907e-16]]))
The eigenvalues are e-16
means
Example
Determine the eigenvalues and eigenvectors of
[ 3.+0.j -3.+0.j 3.+0.j]
[[ 0.81649658 0.57735027 0.22645541]
[ 0.40824829 -0.57735027 0.79259392]
[-0.40824829 0.57735027 0.56613852]]
The eigenvalue
Eignevalue
Eignevalue
To rescale the two eigenvectors corresponding to eigenvalue
- select the first column of the eigenvectors array.
- rescale by dividing through by the second entry.
- select the third column of the eigenvectors array.
- rescale by dividing through by the first entry (since it is the smallest). Once we do this we'll see that the numbers are fractions ending in
, so we scale by .
Notice that these two eigenvectors are not orthogonal. One way to fix this is to use .eigh
instead of eig
since the matrix
[-3. 3. 3.]
[[ 0.57735027 0. 0.81649658]
[-0.57735027 0.70710678 0.40824829]
[ 0.57735027 0.70710678 -0.40824829]]
Rescaling the vectors corresponding to eigenvalue