# Trace Of Matrix

Matrix has a special function called trace function. If $A$ is a square matrix then the sum of its main diagonal entry is called trace of matrix $A$ and is denoted by $tr(A)$.

Let $A$ be a square matrix with size $n\times n$, then $A = \begin{bmatrix}a_{11} & a_{12} & a_{13}\\a_{21} & a_{22} & a_{23}\\a_{31} & a_{32} & a_{33}\end{bmatrix}$ $A = \begin{bmatrix}a_{11} & a_{12} & a_{13}\\a_{21} & a_{22} & a_{23}\\a_{31} & a_{32} & a_{33}\end{bmatrix}$

The trace of matrix is $tr(A) = a_{11} + b_{22} + c_{33}$ $tr(A) = a_{11} + b_{22} + c_{33}$

Let is see few examples of traces of matrices.

Example #1

Let A be a square matrix of size $3 \times 3$ $3 \times 3$ $A = \begin{bmatrix}-1 & 4 & 2\\6 & 2 & 7\\5 & 1 & 8\end{bmatrix}$ $A = \begin{bmatrix}-1 & 4 & 2\\6 & 2 & 7\\5 & 1 & 8\end{bmatrix}$

The trace of matrix is $tr(A) = (-1) + 2 + 8 = 9$ $tr(A) = (-1) + 2 + 8 = 9$ $tr(A) = 9$ $tr(A) = 9$

Example #2

Let B be a square matrix of size $4 \times 4$ $4 \times 4$ $B = \begin{bmatrix}6 & 1 & 1 & -2\\5 & 9 & -1 & 3\\0 & 1 & 7 & 2\\3 & 7 & 8 & 5\end{bmatrix}$ $B = \begin{bmatrix}6 & 1 & 1 & -2\\5 & 9 & -1 & 3\\0 & 1 & 7 & 2\\3 & 7 & 8 & 5\end{bmatrix}$

The trace of matrix is $tr(B) = 6 + 9 + 7 + 5 = 27$ $tr(B) = 6 + 9 + 7 + 5 = 27$ $tr(B) = 27$ $tr(B) = 27$

If the matrix A is not a square matrix, then $tr(A)$ is not defined.