# Identifying the order of the output [closed]

How to identify which eigenvalue corresponds to which diagonal entry of the matrix. Here is an example:

Input: {{b, 0, 0, 0}, {0, a, 0, 0}, {0, 0, d, e}, {0, 0, e, c}}

Eigenvalues[%]

Output: {a, b, 1/2 (c + d - Sqrt[c^2 - 2 c d + d^2 + 4 e^2]),
1/2 (c + d + Sqrt[c^2 - 2 c d + d^2 + 4 e^2])}


From the above, the order has seemingly changed.

• In general there is no such association. What exactly are you trying to do? Are there restrictions on the types of matrices you have in mind? Commented Jun 26 at 1:50
• From the documentation of Eigensystem, "all the nonzero eigenvectors given are independent. If the number of eigenvectors is equal to the number of nonzero eigenvalues, then corresponding eigenvalues and eigenvectors are given in corresponding positions in their respective lists. The eigenvalues correspond to rows in the eigenvector matrix." Commented Jun 26 at 16:53

Eigensystem[{{b, 0, 0, 0}, {0, a, 0, 0}, {0, 0, d, e}, {0, 0, e, c}}]
(*
{{a, b,
1/2 (c + d - Sqrt[c^2 - 2 c d + d^2 + 4 e^2]),
1/2 (c + d + Sqrt[c^2 - 2 c d + d^2 + 4 e^2])},
{{0, 1, 0, 0}, {1, 0, 0, 0},
{0, 0, -((c - d + Sqrt[c^2 - 2 c d + d^2 + 4 e^2])/(2 e)), 1},
{0, 0, -((c - d - Sqrt[c^2 - 2 c d + d^2 + 4 e^2])/(2 e)), 1}}}
*)

• How to distinguish between the 3rd and 4th? Commented Jun 25 at 21:57
• What do you mean? They are not the diagonal entries. Commented Jun 26 at 4:11

You may need to consolidate Mathematica code that computes the eigenvalues of the matrix and directly outputs them:

(* Define the matrix *)
matrix = {{b, 0, 0, 0}, {0, a, 0, 0}, {0, 0, d, e}, {0, 0, e, c}};

(* Compute and display the eigenvalues *)
Eigenvalues[matrix]


When you run this single block of code in Mathematica, it will compute and display the eigenvalues of the matrix. The output will be:

{a, b, 1/2 (c + d - Sqrt[c^2 - 2 c d + d^2 + 4 e^2]),
1/2 (c + d + Sqrt[c^2 - 2 c d + d^2 + 4 e^2])}


Edit: Here is the corrected and improved code based on the OP's requirements:

(* Define the matrix *)
A = {{b, 0, 0, 0}, {0, a, 0, 0}, {0, 0, d, e}, {0, 0, e, c}};

(* Compute eigenvalues and eigenvectors of the original matrix *)
{eigenvalues, eigenvectors} = Eigensystem[A];

(* Output eigenvalues and corresponding eigenvectors *)
{eigenvalues, eigenvectors}


• whats the point? I already know this. Please read the question carefully. Commented Jun 25 at 21:54
• @SciJewel I have reviewed your question again and improved the code to directly address your specific requirements. The issue of matching eigenvalues to their corresponding diagonal entries has been resolved Commented Jun 25 at 23:16