# 07. Index notation

## 07. Index notation

### Index notation

I can write the entries of an $m$ -by-$n$ matrix $A$ as $A=\begin{pmatrix}A_{11}&A_{12}&A_{13}&\cdots&A_{1n}\\ A_{21}&A_{22}&A_{23}&\cdots&A_{2n}\\ \vdots&\vdots&\vdots&&\vdots\\ A_{m1}&A_{m2}&A_{m3}&\cdots&A_{mn}\end{pmatrix}.$ Here $A_{ij}$ denotes the entry sitting in the $i$ th row and the $j$ th column.

One advantage of writing matrices like this is that it gives a compact formula for operations like matrix multiplication: rather than writing out the full matrix $AB$ , we can just write a formula for the $ij$ th entry $(AB)_{ij}$ . Suppose that $A$ is $m$ -by-$n$ and $B$ is $n$ -by-$p$ .

To get $(AB)_{ij}$ , we need to multiply the $i$ th row of $A$ into the $j$ th column of $B$ , in other words: $(AB)_{ij}=\begin{pmatrix}A_{i1}&A_{i2}&\cdots&A_{in}\end{pmatrix}\begin{% pmatrix}B_{1j}\\ B_{2j}\\ \vdots\\ B_{nj}\end{pmatrix}$ $=A_{i1}B_{1j}+A_{i2}B_{2j}+\cdots+A_{in}B_{nj}$ $=\sum_{k=1}^{n}A_{ik}B_{kj}.$ In this last step, we just introduced a "dummy index" $k$ to keep track of the terms in the sum. We now have a nice compact formula for the $ij$ th entry of $AB$ : it's $\sum_{k=1}^{n}A_{ik}B_{kj}$ .

### Associativity of matrix multiplication

To demonstrate how useful index notation is, let's prove that matrix multiplication is associative, that is: $(AB)C=A(BC).$ We can just write out the formula for the $ij$ th entry on each side and check they give the same answer. For the left-hand side: $((AB)C)_{ij}=\sum_{k}(AB)_{ik}C_{kj}$ $=\sum_{k}\sum_{\ell}A_{i\ell}B_{\ell k}C_{kj}$ where we've used the formula for matrix multiplication twice (using all sorts of different letters). Note that the second time I use the formula, I can't use the letter $k$ for my dummy index because $k$ already means something in the expression; that's why I introduced $\ell$ .

For the right-hand side: $(A(BC))_{ij}=\sum_{k}A_{ik}(BC)_{kj}$ $=\sum_{k}A_{ik}\sum_{\ell}B_{k\ell}C_{\ell j}$ We can take the factor $A_{ik}$ inside the sum (just by multiplying out the whole expression), which gives: $(A(BC))_{ij}=\sum_{k}\sum_{\ell}A_{ik}B_{k\ell}C_{\ell j}.$

This looks very similar to the formula for the left-hand side, but the indices $k$ and $\ell$ have been swapped. That doesn't matter: $k$ and $\ell$ are dummy indices, so we can just rename them. We'll relabel $k$ as $\ell$ and $\ell$ as $k$ : $(A(BC))_{ij}=\sum_{\ell}\sum_{k}A_{i\ell}B_{\ell k}C_{kj}.$ Finally, we can switch the order of the sums without worrying because they're finite sums. This gives exactly the same formula that we had on the left-hand side.

Index notation is very heavily used in subjects like general relativity. For example, the Riemann curvature tensor $R^{i}_{\ jk\ell}$ is an object with four indices, some up and some down!