# matrix notation used when computing trace

A linear algebra text I'm reading defines Matrix multiplication as $(AB)_{ij}=\sum_{k=1}^nA_{ik}B_{ki}$

Later on in the text they define the trace formula as $tr(AB)=\sum_{i}^n(AB)_{ii}$

What confuses me is that is that since the first formula simply describes a matrix, then based on their notation, doesn't the second describe the sum of all elements? I don't see how it says anything specific about the diagonal. What I get from $(AB)_{ii}$ is that $AB$ is a square matrix, which makes sense since we want the trace. but I still don't see how the second summation formula describes summing the diagonals.

By definition

$tr(AB)=\sum_{i}^n(AB)_{ii}$ = sum of all elements along the diagonal

infact $(AB)_{ii}$ indicates the element on row i and column i $\equiv$ the i-th element on the diagonal

• Thanks. and I was still a bit confused with the schwarz inequality in the other post. I will hopefully get some time later today to review it and specify in the comment section what exactly is giving me trouble Dec 7, 2017 at 11:33

Note that $(A)_{ij}$ is the number which is in row $i$ column $j$. Thus $(AB)_{ij}$ as you write above is not the whole matrix, but rather $AB$ is the matrix such that on position $(i,j)$ we have the number $(AB)_{ij}$.

When defining the trace as the sum $\sum _{i}^n (AB)_{ii}$ we only use the fact that $(AB)_{ii}$ is a number, and sum together all these numbers. This will clearly be a new number, and without putting it into a matrix (as we did implicitly for matrix multiplication) it will just be a number, which we here call the trace. The diagonal of a matrix is defined as the umbers who is on the same row as column, i.e. the numbers on position $(AB)_{ii}$.

• If $(A)_{ij}$ just describes the position of an element in a matrix, then why define it as a sum? Or is it the case that $(A)_{ij}$ is not defined as a sum, but only $(AB)_{ij}$ since the elements would be determined by the sum? Dec 7, 2017 at 11:05
• @OveAhlman, you have missed out a pair of dollar sign. Dec 7, 2017 at 11:09
• @johnfowles $(A)_{ij}$ is not the position; it's the number in $i,j$ position. Could you explain your question a bit more? Dec 7, 2017 at 11:12
• @Botond IF $(A)_{ij}$ describes the number in $i,j$ position then the trace formula makes sense. I just don't see how the definition $(AB)_{ij}=\sum_{k=1}^nA_{ik}B_{ki}$ specifies the number in $i,j$ position. I do believe that I see my mistake now. This definition is exclusively for matrix multiplication and shows the process of summing products which gives the element in $i,j$ position. Dec 7, 2017 at 11:16
• $\sum_{k=1}^{n} A_{ik}B_{kj}=A_{i1}B_{1j}+A_{i2}B_{2j}+A_{i3}B_{3j}+...+A_{in}B_{nj}$ is just a number, the element in the $i,j$ position. Dec 7, 2017 at 11:19