# Plotting the Eigenvectors with respect to a parameter

I have a matrix $$M(\lambda)$$ of the form given below with a parameter $$\lambda$$. I would like to plot the quantity $$\langle\phi_{i}|Q|\phi_{i}\rangle$$ for every Eigenvectors corresponding to ascending order in Eigenvalues of this matrix with respect $$\lambda$$.Here $$|\phi_{i}\rangle$$ are the eigen vector of the matrix $$M$$.

I am having a bit of trouble to sort the eigenvectors and plot it w.r.t $$\lambda$$.

Could somebody help me to get that.

M=[{0.5, 0., 0., 0. + [\lambda], 0.000141421, 0., 0., 0.},{0., -0.5, 0. + \[Lambda], 0., 0., 0.000141421, 0., 0.},
{0., 0. + \[Lambda], 1.5, 0., 0., 0. + Sqrt[2] \[Lambda], 0.000244949, 0.},
{0. + \[Lambda], 0., 0., 0.5, 0. + Sqrt[2] \[Lambda], 0., 0., 0.000244949},
{0.000141421, 0., 0., 0. + Sqrt[2] \[Lambda], 2.5, 0., 0., 0. + Sqrt[3] \[Lambda]},
{0., 0.000141421, 0. + Sqrt[2] \[Lambda], 0., 0., 1.5,0. + Sqrt[3] \[Lambda], 0.},
{0., 0., 0.000244949, 0., 0., 0. + Sqrt[3] \[Lambda], 3.5, 0.},
{0., 0., 0., 0.000244949, 0. + Sqrt[3] \[Lambda], 0., 0., 2.5}]


The Q Matrix is

Q={{0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0},{0,0,1,0,0,0,0,0},
{0,0,0,1,0,0,0,0},{0,0,0,0,2,0,0,0},{0,0,0,0,0,2,0,0},
{0,0,0,0,0,0,3,0},{0,0,0,0,0,0,0,3}}

• What do you mean by "the norm of the eigenvector"? Eigenvectors are non-unique and are usually normalized to have unit norm for that reason. This is what Eigenvectors and Eigensystem do for numeric matrices. For matrices involving symbols (like yours), these functions just pick representations that have convenient symbolic forms, which is why they're not usually normalized in that case. Jul 17, 2020 at 10:30
• You could start by Plot[Eigenvalues[M[\[Lambda]]] // Evaluate, {\[Lambda], 0, 25}] Jul 17, 2020 at 10:30
• @Chris: I would like to plot norm of the eigenvector not the eigenvalues itself. The eigenvector has to be taken in the ascending order in its eigenvalues.
– AVM
Jul 17, 2020 at 10:32
• @AVM The norm of an eigenvector is a meaningless concept unless you give more detail about constraints on the eigenvectors. If x is an eigenvector of M, then so is s*x for any scalar s. You can create eigenvectors of any norm you want. Jul 17, 2020 at 10:37
• @Sjorerd: Thanks for your reply. Here I have done a mistake in writing the question. One operator I have to introduced.
– AVM
Jul 17, 2020 at 10:38

Fixing the problem a bit:

M[λ_] = {{0.5, 0, 0, λ, 0.000141421, 0, 0, 0},
{0, -0.5, λ, 0, 0, 0.000141421, 0, 0},
{0, λ, 1.5, 0, 0, Sqrt[2] λ, 0.000244949, 0},
{λ, 0, 0, 0.5, Sqrt[2] λ, 0, 0, 0.000244949},
{0.000141421, 0, 0, Sqrt[2] λ, 2.5, 0, 0, Sqrt[3] λ},
{0, 0.000141421, Sqrt[2] λ, 0, 0, 1.5, Sqrt[3] λ, 0},
{0, 0, 0.000244949, 0, 0, Sqrt[3] λ, 3.5, 0},
{0, 0, 0, 0.000244949, Sqrt[3] λ, 0, 0, 2.5}};

Q = {{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 2, 0, 0, 0},
{0, 0, 0, 0, 0, 2, 0, 0},
{0, 0, 0, 0, 0, 0, 3, 0},
{0, 0, 0, 0, 0, 0, 0, 3}};


For a given value of $$\lambda$$ you can compute the eigenvalues and eigenvectors, and sort them, with

es[λ_?NumericQ] := Sort[Transpose[Eigensystem[M[N[λ]]]]]


and plot your expectation values with

Plot[#[[2]].Q.#[[2]] & /@ es[λ], {λ, 0, 1}]


### Update

If you only need the three lowest eigenvalues, use es[λ][[;;3]]:

Plot[#[[2]].Q.#[[2]] & /@ es[λ][[;; 3]], {λ, 0, 1}]


For improved speed (large matrices) you can try to restrict the calculation to the three lowest eigenvalues, instead of calculating all eigenvalues and extracting the three lowest ones.

• Thanks a lot. This plotting I was expecting. I would like to know about Plot[#[[2]]. Is it for the 2nd Eigenvector?
– AVM
Jul 17, 2020 at 12:10
• Pl tell me what does the symbol N signify in [M[N[λ]]]]] ?
– AVM
Jul 17, 2020 at 12:23
• Please have a look at the official documentations of Slot, Part, and N. Jul 17, 2020 at 12:33
• Thanks for your information. If I would like to plot first three eigenvector corresponding to three lowest Eigenvalues, What I have to do?
– AVM
Jul 17, 2020 at 12:46
• This is needed because if I increase the dim. of M matrix, the number of graphs also increases. So If I am interested to first few of them e.g. 3, what I should do? What command I have to modify. Pl let me know.
– AVM
Jul 17, 2020 at 12:49