The Trace of a Square Matrix

The Trace of a Square Matrix

Before we look at what the trace of a matrix is, let's first define what the main diagonal of a square matrix is.

Definition: If $A$ is an square $n \times n$ matrix, then the Main Diagonal of $A$ consists of the entries $a_{11}, a_{22}, ..., a_{nn}$ (entries whose row number is the same as their column number).

The following image is a graphical representation of the main diagonal of a square matrix.

Screen%20Shot%202014-06-07%20at%2011.51.26%20PM.png

We are now ready to looking at the definition of the trace of a square matrix.

Definition: If $A$ is a square $n \times n$ matrix, then the Trace of $A$ denoted $\mathrm{tr}(A)$ is the sum of all of the entries in the main diagonal, that is $tr(A) = \sum_{i=1}^n a_{ii}$. If $A$ is not a square matrix, then the trace of $A$ is undefined.

Calculating the trace of a matrix is relatively easy. For example, given the following $4 \times 4$ matrix $A = \begin{bmatrix} 3 & 2 & 0 & 4\\ 4 & 1 & -2 & 3\\ -3 & -2 & -4 & 7 \\ 3 & 1 & 1 & 5 \end{bmatrix}$ then $\mathrm{tr}(A) = 3 + 1 + (-4) + 5 = 5$.

Example 1

Given the following matrix $B$, calculate $\mathrm{tr}(B)$:

(1)
\begin{align} B = \begin{bmatrix} 1 & 2 & 3 & 4 & 2\\ - 4 & 11 & 5 & 2 & 0\\ -1 & 0 & 3 & \pi & 3\\ 22 & 5 & 3 & 1 & 1\\ 3 & 5 & -22 & 1 & 14 \end{bmatrix} \end{align}

We note that there are five entries of the main diagonal, that is $b_{11} = 1, \: b_{22} = 11, \: b_{33} = 3, \: b_{44} = 1, \: b_{55} = 14$. The sum of these entries is the trace of $B$, that is $\mathrm{tr}(B) = 1 + 11 + 3 + 1 + 14 = 30$.

Example 2

Find all values of $n$ such that $\mathrm{tr}(C) = 23$.

(2)
\begin{align} C = \begin{bmatrix} 3 & n & 2n \\ 0 & n^2 & 1\\ 2 & 3n& 4 \end{bmatrix} \end{align}

We only give notice to entries in the main diagonal. By the definition of a trace of a matrix, it follows that $\mathrm{tr}(C) = 3 + n^2 + 4$. We were given that $\mathrm{tr}(C) = 23$, and we can therefore solve for $n$ as follows:

(3)
\begin{align} \mathrm{tr}(C) = 3 + n^2 + 4 \\ 23 = 3 + n^2 + 4 \\ 16 = n^2 \\ n = 4, \: -4 \end{align}

Hence $n = \pm 4$ then $\mathrm{tr} (C) = 23$.

Example 3

Prove that if $C = A + B$, then $\mathrm{tr}(C) = \mathrm{tr}(A) + \mathrm{tr}(B)$ (assume $A, \: B, \: C$ are all $n \times n$ square matrices).

  • Proof: If $C = A + B$, then:
(4)
\begin{align} C = \begin{bmatrix} a_{11} + b_{11} & * & * & * \\ * & a_{22} + b_{22} & * & * \\ * & * & \ddots & *\\ * & * & * & a_{nn} + b_{nn} \end{bmatrix} \end{align}
  • And therefore we have that:
(5)
\begin{align} \mathrm{tr}(C) = (a_{11} + b_{11}) + (a_{22} + b_{22}) + ... + (a_{nn} + b_{nn}) \\ \mathrm{tr}(C) = a_{11} + a_{22} + ... + a_{nn} + b_{11} + b_{22} + ... + b_{nn} \\ \quad \mathrm{tr}(C) = [a_{11} + a_{22} + ... + a_{nn}] + [b_{11} + b_{22} + ... + b_{nn}] \\ \mathrm{tr}(C) = \mathrm{tr}(A) + \mathrm{tr}(B) \\ \blacksquare \end{align}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License