Apply Eigenvalues to a list of matrices

I would like to apply Eigenvalues[] to a list of matrices as in the following

foo[x_,y_]=x+y;

({{foo[#1, #2], foo[#1, #1]},
{foo[#1, #1], foo[#1, #2]}}) & @@@ {{1, 2}, {1, 2}}

--> {{{3, 2}, {2, 3}}, {{3, 2}, {2, 3}}}

Eigenvalues @@@ %


However, I get the error-message "Eigenvalues::matsq: Argument 3 at position 1 is not a non-empty square matrix". What is the problem?

• You need to use Map, not Apply. Additional braces are not necessary. Mar 25, 2014 at 14:17

Padding additional brackets is not the right way to do it. You should use the right function for the task, which is Map:

matrices = {{{3, 2}, {2, 3}}, {{3, 2}, {2, 3}}};
Eigenvalues /@ matrices


If you're insistent on using Apply (why?), then the following ways work:

Eigenvalues[{##}] & @@@ matrices
Eigenvalues @@@ List /@ matrices

• EigenValues @@@ {matrices} does not do the same thing as the others. Mar 25, 2014 at 14:47
• @RunnyKine Thanks for catching that! Fixed now.
– rm -rf
Mar 25, 2014 at 15:05
• Sure thing. Thanks for fixing it. +1 Mar 25, 2014 at 15:12

I got it: one has to put additional brackets around the first pure function:

{({{foo[#1, #2], foo[#1, #1]},
{foo[#1, #1], foo[#1, #2]}})} & @@@ {{1, 2}, {1, 2}}