The trace of a matrix: Courses and corrected exercises
Contents of this article
This article aims to present the trace of a matrix through its definition, examples and corrected exercises. It is good to have the basic knowledge of what a square matrix is.
Definition
Let A be a square matrix of size n defined by its coefficients (aij). The trace of A, denoted Tr(A) is the sum of the diagonal coefficients of this matrix. With the help of a sum, it is therefore written:
Tr(A) = \sum_{k=1}^n a_{ii}
It is therefore an application of
M_n(\mathbb{K}) \mapsto \mathbb{K}
where K is a field.
Examples
Take the following matrix:
A = \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6\\ 7 & 8 & 9 \end{pmatrix}
The trace of A is then
1 + 5 + 9 = 15
Manufacturing
With the help of a corrected exercise of which here is the statement, we will show the most important properties of matrix traces:

We are going to do these proofs on the field of real numbers but they are more generally valid in a field K.
So let's start by showing the linearity of the trace. Let λ be a real number and A a square matrix of size n.
\begin{array}{ll} Tr(\lambda A) &=\displaystyle \sum_{i=1}^n (\lambda a)_{ii}\\ & =\displaystyle \sum_{i=1}^ n \lambda a_{ii}\\ &=\displaystyle \lambda \sum_{i=1}^n a_{ii}\\ & =\lambda Tr(A) \end{array}
Let B be a square matrix of size n, we have:
\begin{array}{ll} Tr(A+B) &=\displaystyle \sum_{i=1}^n (a+b)_{ii}\\ & =\displaystyle \sum_{i=1}^ n a_{ii}+b_{ii}\\ &=\displaystyle \sum_{i=1}^n a_{ii}+ \sum_{k=1}^n b_{ii}\\ & =Tr(A ) +Tr(B) \end{array}
This shows us the linearity of the trace function. It is therefore a linear form!
Let us show that we can commute two terms:
\begin{array}{ll} Tr(AB) &=\displaystyle \sum_{i=1}^n (ab)_{ii}\\ & =\displaystyle \sum_{i=1}^n\sum_{ j=1}^n a_{ij}b_{ji}\\ & =\displaystyle \sum_{j=1}^n\sum_{i=1}^n a_{ij}b_{ji}\\ &= \displaystyle \sum_{j=1}^n\sum_{i=1}^n b_{ji}a_{ij}\\ & =\displaystyle \sum_{j=1}^n (ba)_{ji} \\ & =Tr(BA) \end{array}
Result : The trace is a similarity invariant. One
B = PAP^{-1}
So we have:
\begin{array}{ll} Tr(B) &= Tr(PAP^{-1})\\ &= Tr(P(AP^{-1}))\\ &= Tr((AP^{- 1})P)\\ &= Tr(A(P^{-1}P))\\ & = Tr(A) \end{array}
For the last property, which is not as classic as the previous ones. If such a matrix of size n existed, we would have:
Tr(AB-BA) = Tr(I_n)
Yet
Tr(AB-BA) = Tr(AB) - Tr(BA)
Et
Tr(AB) = Tr(BA)
So
0 = Tr(I_n) = n
This allows us to arrive at a contradiction!
To note more : The trace is invariant by the transpose:
Tr({}^t A) = Tr(A)
corrected exercise

To do this exercise, we will use a formula established above:
Tr(AM) = \sum_{i=1}^n \sum_{j=1}^n a_{ij}m_{ji}
So we have :
\sum_{i=1}^n \sum_{j=1}^n a_{ij}m_{ji} = \sum_{i=1}^n \sum_{j=1}^n b_{ij}m_ {ji}
Thanks to the matrix M = Elk elementary matrix, we directly obtain
a_{kl} = b_{kl}
because Ilk is the only nonzero term of the sum and equals 1. We therefore have, by varying k and l:
\forall k,l \in \{1, \ldots, n \},a_{kl} = b_{kl}
Hence A = B