Question 5: Repeated Eigenvalues

Enter Wolfram Language code that extracts a list of eigenvalues of the matrix ( − 2 0 − 6 0 − 1 0 4 − 6 0 − 7 0 − 8 18 − 6 − 12 − 43 58 − 6 − 12 − 38 53 ) that have a multiplicity higher than 1 . The result should be a list without any duplicates, with its elements in any order.

[1] [0]

Possible answers include:

Keys[Select[Counts[Eigenvalues[{{2, -6, 1, 4}, {-6, -7, -8, 18}, {-6, -12, -43, 58}, {-6, -12, -38, 53}}]], #1 > 1 &]]

and

First /@ Select[Split[Eigenvalues[{{2, -6, 1, 4}, {-6, -7, -8, 18}, {-6, -12, -43, 58}, {-6, -12, -38, 53}}]], Length[#1] > 1 &]

Step 1 of 6

Use Eigenvalues[A] to extract eigenvalues of the matrix. This returns the list of eigenvalues of matrix A .

Step 2 of 6

Now count the multiplicity of elements in the obtained list:

Counts[Eigenvalues[A]]

This returns an association of the form Association[eigenvalue1 -> multiplicity1, …]:

Counts[Eigenvalues[{{2, -6, 1, 4}, {-6, -7, -8, 18}, {-6, -12, -43, 58}, {-6, -12, -38, 53}}]] = <|-5 -> 1, 5 -> 2, 0 -> 1|>

Step 3 of 6

Select those key-value pairs that have a multiplicity greater than 1 :

Select[Counts[Eigenvalues[A]], #1 > 1 &]

Select[Counts[Eigenvalues[{{2, -6, 1, 4}, {-6, -7, -8, 18}, {-6, -12, -43, 58}, {-6, -12, -38, 53}}]], #1 > 1 &] = <|5 -> 2|>

Step 4 of 6

Obtain the list of those keys. This will have no duplicates, as expected:

Keys[Select[Counts[Eigenvalues[A]], #1 > 1 &]]

Keys[Select[Counts[Eigenvalues[{{2, -6, 1, 4}, {-6, -7, -8, 18}, {-6, -12, -43, 58}, {-6, -12, -38, 53}}]], #1 > 1 &]] = {5}

Step 5 of 6

Another alternative way would be to use Split. It splits a list into sublists of consecutive identical elements. We can apply Split on Eigenvalues since it returns identical values consecutively by default:

Split[Eigenvalues[A]]

Split[Eigenvalues[{{2, -6, 1, 4}, {-6, -7, -8, 18}, {-6, -12, -43, 58}, {-6, -12, -38, 53}}]] = {{-5}, {5, 5}, {0}}

Now select the elements with multiplicity more than 1 :

Select[Split[Eigenvalues[A]], Length[#1] > 1 &]

Select[Split[Eigenvalues[{{2, -6, 1, 4}, {-6, -7, -8, 18}, {-6, -12, -43, 58}, {-6, -12, -38, 53}}]], Length[#1] > 1 &] = {{5, 5}}

Get the list of those eigenvalues from the selected sublists by mapping First over the list:

First /@ Select[Split[Eigenvalues[A]], Length[#1] > 1 &]

First /@ Select[Split[Eigenvalues[{{2, -6, 1, 4}, {-6, -7, -8, 18}, {-6, -12, -43, 58}, {-6, -12, -38, 53}}]], Length[#1] > 1 &] = {5}

Step 6 of 6

Possible Wolfram Language expressions for finding the eigenvalues with multiplicity greater than 1 include (not exhaustive):

Keys[Select[Counts[Eigenvalues[{{2, -6, 1, 4}, {-6, -7, -8, 18}, {-6, -12, -43, 58}, {-6, -12, -38, 53}}]], #1 > 1 &]]

and

First /@ Select[Split[Eigenvalues[{{2, -6, 1, 4}, {-6, -7, -8, 18}, {-6, -12, -43, 58}, {-6, -12, -38, 53}}]], Length[#1] > 1 &]

Many other Wolfram Language expressions that correctly compute the list of eigenvalues with multiplicity greater than 1 are also accepted.