# Matrix trace worksheet for college students

Matrix trace is a scaler that gives quick information on the regularities of matrices such as similarity and other properties. In this article, we give a nice matrix trace worksheet to help students.

Definition: A trace of the matrix $A=(a_{ji})_{1\le i,j\le n}$ is the scalar number \begin{align*}{\rm Tr}(A)=\sum_{i=1}^n a_{ii}.\end{align*}

Example: The trace of the matrix \begin{align*} A=\begin{pmatrix} 1&4&0\\2&0&5\\1&1&88\end{pmatrix}\end{align*} is $99$.

### Matrix trace worksheet

Exercise 1: Let $A\in\mathcal{M}_{n,p}(\mathbb{C})$ and $B\in\mathcal{M}_{p,n}(\mathbb{C})$ be two matrices. Prove that \begin{align*} {\rm Tr}(AB)={\rm Tr}(BA). \end{align*}

Solution: let $a_{ij},$ $b_{ij}$, $c_{ij}$ and $d_{ij}$ be the entries of the matrices $A,B,AB$ and $BA$ respectively. Observe that $AB$ us a square matrix of order $n$ and $BA$ is a matrix of order $p$. We have \begin{align*} c_{ij}=\sum_{k=1}^p a_{ik}b_{kj},\quad d_{ij}=\sum_{k=1}^n b_{ik}a_{kj}. \end{align*} Then by definition of trace we have \begin{align*} {\rm Tr}(AB)&=\sum_{i=1}^n c_{i,i}\cr&= \sum_{i=1}^n \left(\sum_{k=1}^p a_{ik}b_{ki}\right). \end{align*} On the other hand, \begin{align*} {\rm Tr}(BA)&=\sum_{i=1}^n d_{i,i}\cr&= \sum_{i=1}^p \left(\sum_{k=1}^n b_{ik}a_{ki}\right)\cr&= \sum_{i=1}^n \left(\sum_{k=1}^p a_{ik}b_{ki}\right)\cr & ={\rm Tr}(AB). \end{align*}

Exercice: Does exist matrices $A,B\in\mathcal{M}_n(\mathbb{C})$ such that $AB-BA=I_n$?

Solution: Assume that $AB-BA=I_n$. As the trace operation is linear and ${\rm Tr}(I_n)=n,$ then \begin{align*} {\rm Tr}(AB)-{\rm Tr}(BA)=n. \end{align*} According to Exercise 1, we have ${\rm Tr}(AB)={\rm Tr}(BA)$. Absurd!!!

Exercise: Assume that matrices $A,B\in\mathcal{M}_n(\mathbb{C})$ satisfy \begin{align*} (AB-BA)^2=AB-BA. \end{align*} Show that $AB=BA$.

Solution: We put $N=AB-BA,$ so that $N^2=N$. This means that $N$ is the matrix associated to a projector $p$. Then ${\rm Tr}(p)={\rm Tr(N)}=0$. But it is known that ${\rm Tr}(p)=\mathcal{R}(p)$ (range of $p$). Hence $\mathcal{R}(p)=0$. This implies that $\ker(p)=\mathbb{C}$ (we recall that for a projector we have the direct sum $\mathbb{C}^n=\ker(p)+\mathcal{R}(p)$). This means that $N=0_n$ (the null matrix). Finally, $AB=BA$.

Exercise: Let $A,B\in\mathcal{M}_n(\mathbb{R})$. Solve, in $\mathcal{M}_n(\mathbb{R}),$ the following matrices equation \begin{align*} X={\rm Tr}(X)A+B. \end{align*}

Solution: To solve the equation it suffices to determine ${\rm Tr}(X)$. By taking trace of $X$ and ${\rm Tr}(X)A+B,$ we obtain \begin{align*} {\rm Tr}(X)={\rm Tr}(X){\rm Tr}(A)+{\rm Tr}(B). \end{align*} This implies that \begin{align*}\tag{H} (1-{\rm Tr}(A)){\rm Tr}(X)={\rm Tr}(B) \end{align*} We distinct two cases:

If ${\rm Tr}(A)\neq 1$, then we have \begin{align*} {\rm Tr}(X)=\frac{{\rm Tr}(B)}{1-{\rm Tr}(A)}. \end{align*} This implies that the solution of the matrix equation is \begin{align*} X=\frac{{\rm Tr}(B)}{1-{\rm Tr}(A)}\; A+B. \end{align*}

>Assume that ${\rm Tr}(A)=1$. If ${\rm Tr}(B)\neq 0$, then the equation is not compatible and there is no solutions to the matrix equation. Now if ${\rm Tr}(B)= 0,$ then the condition (H) is verified for any condition on $X$. In particular if $\lambda={\rm Tr}(X)$, then $X=\lambda A+B$ is a solution.