# Defining functions with parameters

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

es[1,1,1,1]


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

eiginst[1,1,1,1]
Transpose::list: List expected at position 2 in <<1>>. >>

• 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]] Dec 3, 2015 at 16:57
• 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]]]. Dec 3, 2015 at 16:59
• Yes you are right !Thanks a lot. I made this mistake when i changed the code. Sorry for asking this. Dec 3, 2015 at 17:04
• 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! Dec 3, 2015 at 17:05
• I would like to accept the answer, but since it was posted in a comment I cant accept it. Dec 3, 2015 at 17:20

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