I want to change my code in which I set the global values of my parameters in the beginning, to a code in which I leave the parameter values undefined in the definition of functions. Take for example this part of my code where H is some Matrix dependent on the Parameters t and U:

es[t_, U_] := Eigensystem[N[(H[t, U])]];
eiginst[t_, U_] := SortBy[Transpose[es[t, U], #[[1]] &]]

Whilst I am still able to excecute


and get the correct result,I get an error when I excecute the second function:

Transpose::list: List expected at position 2 in <<1>>. >>
  • 1
    $\begingroup$ The problem is not with the es funtion but with the second argument you pass to function Transpose; specifically I am reffering to this: #[[1]] $\endgroup$ Dec 3, 2015 at 16:57
  • $\begingroup$ Yeah: it looks like a case of mis-placed closing brackets: perhaps this is what you want: eiginst[t_, U_] := SortBy[Transpose[es[t, U]], #[[1]] &]. If so , I think you can just do eiginst[t_, U_] := Sort[Transpose[es[t, U]]]. $\endgroup$
    – march
    Dec 3, 2015 at 16:59
  • $\begingroup$ Yes you are right !Thanks a lot. I made this mistake when i changed the code. Sorry for asking this. $\endgroup$
    – Falafel
    Dec 3, 2015 at 17:04
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – Michael E2
    Dec 3, 2015 at 17:05
  • $\begingroup$ I would like to accept the answer, but since it was posted in a comment I cant accept it. $\endgroup$
    – Falafel
    Dec 3, 2015 at 17:20

1 Answer 1


Based on provided code, following code addressed the outlined issue:


es[t_, U_] := Eigensystem[N[(H[t, U])]];
eiginst[t_, U_] := Sort[Transpose[es[t, U]]];



Credits to @march !


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.