# How to define function in Mathematica

I have a 3 by 3 symbolic matrix M(x,y,z).

Question:1

First, I want to find its eigenvalues and eigenvectors. After that I want to make each eigenvalue and eigenvector a function of x,y, and z i.e.

(*long expression to calcualte M[kx_,ky_,kz_]*)
{vals, vecs} = Eigensystem[M[x, y, z]];
(*I want to get expression like
e1[x_,y_,z_]:=first_eigenvalue;
v1[x_,y_,z_]:=first_eigenvector; same for remaining*)


I tried e1[x_,y_,z_]:=vals[[1]], it does not work.

Question:2

at some point, I want to take ConjugateTranspose[] of v1 (or v2, v3). Assuming that like MATLAB, Mathematica also give eigenvector in the column, I defined v1 as vecs2 = Transpose[vecs]; v1=[[1]]; Now, when I try ConjugateTranpose[v1]; it gives an erorr that The first two levels ... can't be transposed

• e1 = Function[{x, y, z}, Evaluate[vals]]; v1 = Function[{x, y, z}, Evaluate[vecs]]; You can then use them like functions for example e1[a,b,c] or v1[1,2,3] will substitute the x,y,z values for the arguments. Oct 29, 2020 at 20:22
• e1[x_, y_, z_] = vals[[1]] and v1[x_,y_,z_] = vecs[[1]] works. I suggest you learn about immediate and delayed assignments and how they differ. Oct 29, 2020 at 21:14