Trace

Tr(A) is only defined for a Square Matrix.

Given a square matrix AA,

tr(A)=a11+a22+...+ann\begin{gather*} tr(A)=a_{11}+a_{22}+...+a_{nn} \end{gather*}

Note that

tr(AB)=tr(BA)\begin{gather*} tr(AB)=tr(BA) \end{gather*}

Traces are just adding diagonals together

tr(T^)=nnT^n=nTnn\begin{gather*} tr(\hat{T})=\sum_n\left\langle n \right\rvert\hat{T}\left\lvert n \right\rangle=\sum_nT_{nn} \end{gather*}

Properties:

tr(A^B^)=tr(B^A^)tr(A^B^C^)=tr(B^C^A^)=tr(C^A^B^)\begin{gather*} tr(\hat{A}\hat{B})=tr(\hat{B}\hat{A})\\ tr(\hat{A}\hat{B}\hat{C})=tr(\hat{B}\hat{C}\hat{A})=tr(\hat{C}\hat{A}\hat{B}) \end{gather*}

Note that tr(A^B^C^)tr(A^C^B^)tr(\hat{A}\hat{B}\hat{C})\neq tr(\hat{A}\hat{C}\hat{B}) → it must be cyclical permutation

tr(αA^+βB^)=αtr(A^)+βTr(B^)\begin{gather*} tr(\alpha\hat{A}+\beta\hat{B})=\alpha tr(\hat{A})+\beta Tr(\hat{B}) \end{gather*}

Also note that if you get the traces of a 1×11\times 1 matrix, it is just

tr((a))=atr(\begin{pmatrix}a\end{pmatrix})=a