# 07. Index notation

## 07. Index notation

### Index notation

I can write the entries of an $m$ -by-$n$ matrix $A$ as $$A=\left(\begin{array}{ccccc}\hfill {A}_{11}\hfill & \hfill {A}_{12}\hfill & \hfill {A}_{13}\hfill & \hfill \mathrm{\cdots}\hfill & \hfill {A}_{1n}\hfill \\ \hfill {A}_{21}\hfill & \hfill {A}_{22}\hfill & \hfill {A}_{23}\hfill & \hfill \mathrm{\cdots}\hfill & \hfill {A}_{2n}\hfill \\ \hfill \mathrm{\vdots}\hfill & \hfill \mathrm{\vdots}\hfill & \hfill \mathrm{\vdots}\hfill & \hfill \hfill & \hfill \mathrm{\vdots}\hfill \\ \hfill {A}_{m1}\hfill & \hfill {A}_{m2}\hfill & \hfill {A}_{m3}\hfill & \hfill \mathrm{\cdots}\hfill & \hfill {A}_{mn}\hfill \end{array}\right).$$ 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}=\left(\begin{array}{cccc}\hfill {A}_{i1}\hfill & \hfill {A}_{i2}\hfill & \hfill \mathrm{\cdots}\hfill & \hfill {A}_{in}\hfill \end{array}\right)\left(\begin{array}{c}\hfill {B}_{1j}\hfill \\ \hfill {B}_{2j}\hfill \\ \hfill \mathrm{\vdots}\hfill \\ \hfill {B}_{nj}\hfill \end{array}\right)$$ $$={A}_{i1}{B}_{1j}+{A}_{i2}{B}_{2j}+\mathrm{\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 _{\mathrm{\ell}}{A}_{i\mathrm{\ell}}{B}_{\mathrm{\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 $\mathrm{\ell}$ .

For the right-hand side: $${(A(BC))}_{ij}=\sum _{k}{A}_{ik}{(BC)}_{kj}$$ $$=\sum _{k}{A}_{ik}\sum _{\mathrm{\ell}}{B}_{k\mathrm{\ell}}{C}_{\mathrm{\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 _{\mathrm{\ell}}{A}_{ik}{B}_{k\mathrm{\ell}}{C}_{\mathrm{\ell}j}.$$

This looks very similar to the formula for the left-hand side, but the indices $k$ and $\mathrm{\ell}$ have been swapped. That doesn't matter: $k$ and $\mathrm{\ell}$ are dummy indices, so we can just rename them. We'll relabel $k$ as $\mathrm{\ell}$ and $\mathrm{\ell}$ as $k$ : $${(A(BC))}_{ij}=\sum _{\mathrm{\ell}}\sum _{k}{A}_{i\mathrm{\ell}}{B}_{\mathrm{\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}_{jk\mathrm{\ell}}^{i}$ is an object with four indices, some up and some down!