Definition of the (main) diagonal of a matrix
Definition: The main diagonal (or simply diagonal) of a matrix $A = (a_{ij})$ is the set of entries $a_{ii}$ where the row and column indices are equal:
$$\text{diag}(A) = \{a_{11}, a_{22}, a_{33}, \ldots\}$$
For an $m \times n$ matrix, the main diagonal consists of entries where $i = j$, running from the upper-left corner to the lower-right corner.
Example: For
$$A = \begin{pmatrix} \mathbf{1} & 2 & 3 \\ 4 & \mathbf{5} & 6 \\ 7 & 8 & \mathbf{9} \end{pmatrix}$$
the main diagonal entries are $1, 5, 9$.
The trace of a square matrix is the sum of its diagonal entries: $\text{tr}(A) = \sum_i a_{ii}$.