Skip to main content

matrix - How get eigenvectors without phase jump?



I'm using Eigenvectors to get the eigenvectors for some matrixes, but the eigenvectors seems to have some phase jump. Here is an example:


Say we have a 2 by 2 matrix {{2., Exp[I x]}, {Exp[-I x], 2.}} and x is a number. Now if we change x smoothly in some region, we would expect the eigenvector or eigenvalues changes smoothly. But in fact, we see that there are jumps.


eigenVects = 
Table[Eigenvectors[{{2., Exp[I x]}, {Exp[-I x], 2.}}][[1]] /. {a_, b_} -> {a/Sqrt[a^2 + b^2], b/Sqrt[a^2 + b^2]}, {x, π/2 + π/10, 3 π/2 - π/10, π/20}]

We then take the first eigenvector and plot it's real and imaginary part


Row[{ListPlot[Re@Transpose[eigenVects], Joined -> True, 
ImageSize -> 300, Mesh -> All],
ListPlot[Im@Transpose[eigenVects], Joined -> True, ImageSize -> 300,
Mesh -> All]}]


enter image description here


and we see the curves are not smooth but with some jumps in them. These jumps corresponding to a phase factor to the eigenvectors from the Eigenvectors function. Normally, an eigenvector times a phase factor would still be a eigenvector, but in my system, the uncontrollable phase factor from the Eigenvectors give me problems.


For comparison, we take the analytical solution of the eigenvectors for this 2 by 2 matrix


myEigenvectors[{{a_, b_}, {c_, d_}}] := Module[{C1, C2},
C1 = {-((-a + d + Sqrt[a^2 + 4 b c - 2 a d + d^2])/(2 c)), 1};
C2 = {-((-a + d - Sqrt[a^2 + 4 b c - 2 a d + d^2])/(2 c)), 1};
{C1/Norm[C1], C2/Norm[C2]}
]


and also plot the Re and Im part of the first eigenvector


eigenVects2 = 
Table[myEigenvectors[{{2., Exp[I x]}, {Exp[-I x], 2.}}][[
1]] /. {a_, b_} -> {a/Sqrt[a^2 + b^2],
b/Sqrt[a^2 + b^2]}, {x, π/2 + π/10,
3 π/2 - π/10, π/20}];

we see the curves are smooth.


enter image description here


So why there are these phase jumps in the results from Eigenvectors, and how to get the eigenvectors without the jumps? (For large matrix analytical solution is not practical.)




Answer



The phase (and length) of the eigenvectors is completely undetermined unless you specify extra conditions in addition to the eigenvalue equation. Given that you don't have any additional conditions, it's not surprising that there is no well-defined way to plot the real and imaginary parts of each eigenvector component.


A simple condition that makes the answer unique is to require that the first component of each eigenvector be real. Also, we can add the requirement of normalization.


Then the procedure would be as follows:


eigenVects = 
Table[Eigenvectors[{{2., Exp[I x]}, {Exp[-I x], 2.}}][[1]] /. {a_,
b_} -> {a/Sqrt[a^2 + b^2], b/Sqrt[a^2 + b^2]}, {x, Pi/
2 + Pi/10, 3 Pi/2 - Pi/10, Pi/20}];

eigenVects2 = Map[Normalize[#/#[[1]]] &, eigenVects];


Row[{ListPlot[Re@Transpose[eigenVects2], Joined -> True,
ImageSize -> 300, Mesh -> All],
ListPlot[Im@Transpose[eigenVects2], Joined -> True,
ImageSize -> 300, Mesh -> All]}]

plots


The blue lines (for the first component) show that the real part is constant due to normalization, and the imaginary part is zero at all times. There are no longer any phase jumps because the phase has been fixed.


You can come up with an arbitrary number of alternative conditions that would result in different plots.


Edit: Bloch sphere representation



The requirements of normalization and a real-valued first component provide us with two equations relating the N complex components of a non-degenerate eigenvector. Each complex component is a pair of two real numbers. Therefore, we are left with 2N2 real numbers to parametrize the eigenvector with the given constraints.


For a two-dimensional vector space over the complex numbers (as in the question), we have N=2 and hence we need just two real numbers to identify an eigenvector. It is often convenient to represent such two-dimensional eigenvectors as points on a Bloch sphere. This works because the most general form of a vector satisfying the above constraints is


(cosθ2eiϕsinθ2)


with 0ϕ<2π and 0θ<π, corresponding to the azimuthal and polar angle of a spherical coordinate system. These angles are the two real parameters I mentioned.


To visualize the list of eigenvectors, we can then trace the motion of the corresponding point on the Bloch sphere, instead of making plots of the eigenvector components as I did earlier. Here is a function that does this visualization:


ClearAll[blochSphere];
blochSphere[ket_] :=
Module[{v = Normalize[N[ket]], vN, θ, ϕ, pt},
vN = Chop[v Exp[-I Arg[First[v]]]];
θ = 2 ArcCos[First[vN]];

ϕ = Arg[Last[vN]];
pt = {Cos[ϕ] Sin[θ], Sin[ϕ] Sin[θ], Cos[θ]};
Graphics3D[{
{Opacity[.5], Sphere[]},
Riffle[
{Blue, Green, Red},
Map[
Arrow[Tube[1.3 {-#, #}]] &, IdentityMatrix[3]
]
],

{Gray, Tube[{{0, 0, 0}, pt}]}, {Glow[White], Sphere[pt, .05]},
Inset[
Framed[
MatrixForm[ket],
Background -> Directive[Opacity[.5], LightBlue],
RoundingRadius -> 5, FrameStyle -> None], pt, {-1.3, 0}]
},
Boxed -> False,
Background -> Darker[Gray], ViewPoint -> {2, 1, 2}
]

]

Apply it to a modified version of the eigenvector list from earlier:


eigenVects = 
Table[Eigenvectors[{{2., Exp[I x]}, {Exp[-I x], Cos[x]}}][[1]], {x,
0, 2 Pi - Pi/20, Pi/20}];

ListAnimate@Map[blochSphere, eigenVects]

animation



Here, I deliberately omitted any phase choice and normalization from the test vectors in eigenVects, because blochSphere is meant to do this automatically. It would for example depict the vectors {1,0} and {I, 0} in exactly the same way because of my requirement that the first component should be real. The vector {10,0} would also look the same because it only differs in its norm.


Comments

Popular posts from this blog

functions - Get leading series expansion term?

Given a function f[x] , I would like to have a function leadingSeries that returns just the leading term in the series around x=0 . For example: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x)] x and leadingSeries[(1/x + 2 + (1 - 1/x^3)/4)/(4 + x)] -(1/(16 x^3)) Is there such a function in Mathematica? Or maybe one can implement it efficiently? EDIT I finally went with the following implementation, based on Carl Woll 's answer: lds[ex_,x_]:=( (ex/.x->(x+O[x]^2))/.SeriesData[U_,Z_,L_List,Mi_,Ma_,De_]:>SeriesData[U,Z,{L[[1]]},Mi,Mi+1,De]//Quiet//Normal) The advantage is, that this one also properly works with functions whose leading term is a constant: lds[Exp[x],x] 1 Answer Update 1 Updated to eliminate SeriesData and to not return additional terms Perhaps you could use: leadingSeries[expr_, x_] := Normal[expr /. x->(x+O[x]^2) /. a_List :> Take[a, 1]] Then for your examples: leadingSeries[(1/x + 2)/(4 + 1/x^2 + x), x] leadingSeries[Exp[x], x] leadingSeries[(1/x + 2 + (1 - 1/x...

mathematical optimization - Minimizing using indices, error: Part::pkspec1: The expression cannot be used as a part specification

I want to use Minimize where the variables to minimize are indices pointing into an array. Here a MWE that hopefully shows what my problem is. vars = u@# & /@ Range[3]; cons = Flatten@ { Table[(u[j] != #) & /@ vars[[j + 1 ;; -1]], {j, 1, 3 - 1}], 1 vec1 = {1, 2, 3}; vec2 = {1, 2, 3}; Minimize[{Total@((vec1[[#]] - vec2[[u[#]]])^2 & /@ Range[1, 3]), cons}, vars, Integers] The error I get: Part::pkspec1: The expression u[1] cannot be used as a part specification. >> Answer Ok, it seems that one can get around Mathematica trying to evaluate vec2[[u[1]]] too early by using the function Indexed[vec2,u[1]] . The working MWE would then look like the following: vars = u@# & /@ Range[3]; cons = Flatten@{ Table[(u[j] != #) & /@ vars[[j + 1 ;; -1]], {j, 1, 3 - 1}], 1 vec1 = {1, 2, 3}; vec2 = {1, 2, 3}; NMinimize[ {Total@((vec1[[#]] - Indexed[vec2, u[#]])^2 & /@ R...

plotting - Plot 4D data with color as 4th dimension

I have a list of 4D data (x position, y position, amplitude, wavelength). I want to plot x, y, and amplitude on a 3D plot and have the color of the points correspond to the wavelength. I have seen many examples using functions to define color but my wavelength cannot be expressed by an analytic function. Is there a simple way to do this? Answer Here a another possible way to visualize 4D data: data = Flatten[Table[{x, y, x^2 + y^2, Sin[x - y]}, {x, -Pi, Pi,Pi/10}, {y,-Pi,Pi, Pi/10}], 1]; You can use the function Point along with VertexColors . Now the points are places using the first three elements and the color is determined by the fourth. In this case I used Hue, but you can use whatever you prefer. Graphics3D[ Point[data[[All, 1 ;; 3]], VertexColors -> Hue /@ data[[All, 4]]], Axes -> True, BoxRatios -> {1, 1, 1/GoldenRatio}]