Search code examples
functionmatrixlinear-algebrawolfram-mathematicaquantum-computing

is it possible to evaluate a function of matrix variables in mathematica?


Let for a matrix X of 3*3 dimension, first I need to find the eigenvectors of it, A = Eigenvectors[X]; Then I need to express one of its eigen vector in matrix form, Lets write its 2nd eigenvector B = A[[2 ;; 2, 1 ;; 3]]; Now I need to evaluvate C = ConjugateTranspose[B].B; Then i need to evaluvate, D = C/Norm[C];

I need to find this for different X, is it possible to write a single function for this?

Can i write code like this

A[X_] := Eigenvectors[X]; B[u_] := A[[2 ;; 2, 1 ;; 3]]; C[y_] := ConjugateTranspose[B].B; D[t_] := C/Norm[C];

and if i need to evaluate the whole thing for a matrix g

D[C[B[A[g]]]]


Solution

  • computeMatrixD[X_] := Module[{A, B, C, D}, A = Eigenvectors[X];
      B = A[[2]];
      B = {B};
      C = ConjugateTranspose[B] . B; 
      D = C / Norm[C];
      D ]
    

    You can write them into one function as above and call it by simply for example:

    X = {{1,2,3}, {2,4,5}, {3,5,6}};
    computeMatrixD[X]