# 07. Index notation

## 07. Index notation

### Index notation

I can write the entries of an m-by-n matrix A as A equals A_{1 1}, A_{1 2}, A_{1 3}, dot dot dot, A_{1 n}; A_{2 1}, A_{2 2}, A_{2 3}, dot dot dot, A_{2 n}; etc up to the final row A_{m 1}, A_{m 2}, A_{m 3}, dot dot dot, A_{m n} Here A_{i j} denotes the entry sitting in the ith row and the jth 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 A B, we can just write a formula for the i jth entry (A B)_{i j}. Suppose that A is m-by-n and B is n-by-p.

To get (A B)_{i j}, we need to multiply the ith row of A into the jth column of B, in other words: (A B)_{i j} = the row A_{i 1}, A_{i 2}, dot dot dot, A_{i n} times the column B_{1 j}, B_{2 j}, dot dot dot, B_{n j}, which equals A_{i 1} times B_{1 j} + A_{i 2} times B _{2 j} plus dot dot dot A_{i n} times B_{n j}, which we write as sum over k from 1 to n of A_{i k} times B_{k j}. 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 i jth entry of A B: it's sum over k from 1 to n of A_{i k} times B_{k j}.

### Associativity of matrix multiplication

To demonstrate how useful index notation is, let's prove that matrix multiplication is associative, that is: brackets A times B close brackets, all times C equals A times brackets B times C close brackets We can just write out the formula for the i jth entry on each side and check they give the same answer. For the left-hand side: the i j entry of brackets A B close brackets C equals sum over k of (A B)_{i k} times C_{k j}, which equals the sum over k and sum over l of A_{i l} B_{e k} C_{k j}, 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 l.

For the right-hand side: the i j entry of A brackets B C close brackets equals sum over k of A_{i k} times (B C)_{k j}, which equals sum over k of A_{i k} times the sum over l of B_{k l} C_{l j}. We can take the factor A_{i k} inside the sum (just by multiplying out the whole expression), which gives: the i j entry of A times brackets B C close brackets equals sum over k and sum over l of A_{i k} B_{k l} C_{l j}.

This looks very similar to the formula for the left-hand side, but the indices k and l have been swapped. That doesn't matter: k and l are dummy indices, so we can just rename them. We'll relabel k as l and l as k: the i j entry of A times brackets B C close brackets equals sum over l and sum over k of A_{i l} B_{l k} C_{k j}. 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 upper i lower j k l is an object with four indices, some up and some down!