Comparing Eigenvectors, Mathematica vs. Matlab
I am trying to create the same out puts in Mathmatica and Matlab, however I am running into trouble aligning the eigenvectors with the eigenvalues, I think the Matlab is doing something slighly more complex (Ordering/Sorting) than I anticpated.
using the example in on the Mathwork website, for [V,D] = eig(A). http://www.mathworks.co.uk/help/matlab/ref/eig.html#btifddh-2
TestMatrix = {{1, 2, 3}, {3, 1, 2}, {2, 3, 1}}
[V,D] = eig(A)
V =
-0.5774 + 0.0000i, 0.2887 - 0.5000i, 0.2887 + 0.5000i,
-0.5774 + 0.0000i, -0.5774 + 0.0000i, -0.5774 + 0.0000i,
-0.5774 + 0.0000i, 0.2887 + 0.5000i, 0.2887 - 0.5000i,
D =
6.0000 + 0.0000i, 0.0000 + 0.0000i, 0.0000 + 0.0000i,
0.0000 + 0.0000i, -1.5000 + 0.8660i, 0.0000 + 0.0000i,
0.0000 + 0.0000i, 0.0000 + 0.0000i, -1.5000 - 0.8660i,
However running this in Mathematica, i recieve the following eigenvector
m = N[Eigensystem[TestMatrix]]
DV = DiagonalMatrix[m[[1]]]
Vec=N[Eigenvectors[TestMatrix]]
Vec={
{1., 1., 1.},
{-<PHONE_NUMBER> I, -0.5 + <PHONE_NUMBER> I, 1.},
{-0.5 + <PHONE_NUMBER> I, -<PHONE_NUMBER> I, 1.}}
This is perfectly acceptable, I just now want to get both vectors into the same form. Note The Diagonal Matrix matches, however I seem unable to recreate V.
From reading the Matwork example, V is right eigenvectors. In this case the Form [V,D] = eig(A) returns matrix V, whose columns are the right eigenvectors of A such that AV = VD. 490
& The eigenvectors in V are normalized so that the 2-norm of each is 1.
Trying to normalise Vec, now in mathematica, I am unable to recreate the results obtained in Matlab. Clearly I am doing something incorrectly, this is where I get a little lost. I have tried the '2-norm' function as described in Matlab, and also the Normalize function, the latter seems a little better but is still incorrect comparing to the results in the matlab example.
Could someone explain where I am going wrong with this, or simply how to recreate the same results in mathematica.
Here are my (...I assume...) incorrect attempts.
Firslty using Normalise.
TestMatrix = {{1, 2, 3}, {3, 1, 2}, {2, 3, 1}}
vec = N[Eigenvectors[TestMatrix]]
Table[Normalize[vec[[i]]], {i, 1, Length[vec]}]
{{0.57735, 0.57735, 0.57735},
{-<PHONE_NUMBER> I, -0.288675 + 0.5 I, 0.57735 + 0. I},
{-0.288675 + 0.5 I, -<PHONE_NUMBER> I, 0.57735 + 0. I}}
This quite close, to the Matlab output V, except the matrix seems to have been transposed, times by a negative, and some how the 2nd and 3rd eigenvalues have been switched (Comparing the Egienvalues and Vector columns) Clearly something has gone wrong, I probably shouldn't have used Normalise.
However my attempts using Norm(p,2) are nowhere near to the final resul.
I see another thread which touches on this topic but doesn't really help. http://stackoverflow.com/questions/5648975/matlab-vs-mathematica-eigenvectors
Can anyone out there explain this? 490