python - Numpy seems to produce incorrect eigenvectors -


I want to use the map to calculate eigenvalues ​​and eigenvectors is my code:

< Import nppy as pre> nmpy numinal import linalg as linal l = np.array ([, 2, -1, -1, 0, 0, 0], [- 1, 3, 0, -1, 0, -1], [-1, 0, 2, -1, 0, 0], [0, -1, -1, 3, -1, 0], [0, 0, 0, - 1, 2, -1], [0, -1, 0, 0, -1, 2]], V = LAp print ('Egnualus:', NP round (W, 0)) print ( 'EgeneVector:', NP.Rend (V, 2))

The result is:

  Eigenvalues: [0. 1. 2. 3. 3. 5. Eigenvectors: [0.41 0.5 0.41 -0.46 0.34 0.2 9] [0.41 0. 0.41 0.53 0.23 -0.58] [0.41 0.5 -0.41 -0.07 -0.57 -0.29] [0.41 0. - 0.41 0.53 0.23 0.58] [0.41 -0.0 -0.41 -0.46 0.34 -0.2 9] [0.41 -0.5 0.41 -0.07 -0.57 0.2 9]]  

However, when I run Wolfram alpha In the same matrix, I get a different result - eigenvalues ​​are similar, but eigenvectors are different:

  v1 = (1, -2, -1, 2, - 1, 1) v2 = (0, -1, -1, -1, 0, 1) v3 = (1, -1, 0, -1, 1, 0) v4 = (1, 1, -1, -1 , -1, v5 = (-1, 0, -1, 0, 1, 1) v6 = (1, 1, 1, 1, 1, 1)  

here Wolfram is a link to Alpha calculations:

Why get me a different result Used to be? What should I do in Python to get the same results created by Alpha?

Thank you very much for the help!

The reasons for the results are different:

  1. You have probably noticed that eigenvectors in oval matrix v have been included horizontally as stacked columns , in the form of rows v1 to

  2. The scale of an eigenvector (or length) is undefined. So it usually grows by length 1. The results of Wolfram are scaled differently, which creates some confusion, I think.

  3. Note that by scaling vectors, even sign can change, positive and negative elements may flip.

  4. And last but not least: The order of eigenvectors is undefined, unless they have the same order as their respective eigenvalues ​​then you will be able to access the eigenvalues ​​of Wolfam Also need to see and possibly v1 to v6 reorder. (This is a general conference based on the size of EginnViews. Wolfam seems sorted in descending order, while in ascending order there is a numerical type.)

  5. In the case of matrix non -Valid eigenvalues ​​, corresponding eigenvectors can rotate uncontrolled, as long as they subspace the corresponding period. However, this does not seem like a case in your example. Given the first 4 issues, the results are really very close, loneliness should not make any difference, because there is only one zero zero in it, thus the associated agenquere is unique (i.e. Sign in and length).


Comments