Reputation: 3505
I am trying to use the numpy
's linalg.eig()
function to get eigenvectors and eigenvalues.
import numpy as np
M = np.array([[168.04570515, 1.38100609, -48.60662242],
[1.38100609, 16.49647382, 9.18370965],
[-48.60662242, 9.18370965, 38.37842496]])
eigenvalue, eigenvector = np.linalg.eig(M)
>>>eigenvalue
array([184.25812834, 28.91371368, 9.74876191])
>>>eigenvector
array([[-0.94849917, -0.26039343, -0.18040119],
[ 0.0095255 , -0.59267178, 0.80538775],
[ 0.31663637, -0.7621912 , -0.56462906]])
However, when I input the same M
values into WolframAlpha, I get the following:
Why do I get different eigenvectors?
Upvotes: 1
Views: 61
Reputation: 972
So you are actually getting the same eigenvectors. It's just that Wolfram Alpha scales the eigenvectors so the last element is 1 (if you recall, eigenvectors are scale invariant). Let's look at the first column of your result. If you run,
np.array([-0.94849917, 0.0095255, 0.31663637])/0.31663637
You will get
array([-2.99554713, 0.0300834 , 1. ])
Which if you notice is what Wolfram Alpha reports. You can check the other two as well.
Upvotes: 1