Why matrix notation makes sense

Published: 12/26/2023

I learned to work and calculate with matrices long ago, but curiously I only recently understood why the common notation for their entries makes sense. This might be embarrassing, but I will share it nevertheless. The insight came from programming.

Let me briefly recall what a matrix is. An by matrix is a rectangular grid of numbers with rows and columns. Here is an example for and . (Perhaps I can convince my MathJax plugin someday to render this properly.)

| 2  3 0 |
| 0 -1 9 |

In mathematics, you denote the matrix entry in row and column by (when the matrix is called , when it is called you write etc.). So in the example above, we therefore have and , for example. A general matrix is then written as

When I first learned this, it seemed a bit strange to me. I was so used to the cartesian coordinate system that, for me, the -coordinate should come first, then the -coordinate. And obviously, the column should be the -coordinate and hence go first, and after that comes the row which is the -coordinate. (Let's ignore for the moment that in a usual cartesian coordinate system the -values grow when you go up, in a matrix it's versa.) Wouldn't it then make more sense to write ?

As with any notation, after some time you just get used to it. I never really had any problems with distinguishing a point on a coordinate system and the location of a matrix entry.

However, the notation makes a lot of sense when you use matrices in programming. To be precise, when you model matrices as 2-dimensional arrays, that is, arrays whose entries are arrays.

How would you model the matrix written above, as a 2-dimensional array? The only reasonable answer is

[
	[2, 3, 0],
	[0, -1, 9]
]

The matrix is an array of rows, and each row is an array. Accordingly, when you want to access the 3 here, you write a[0][1]. First comes the row index 0 and only then the column index 1. Since mathematicians tend to start their indices with 1, they write instead of , but in principle, it's the same. First row, then column.

Of course, you could also do it the other way, but then when you print out the 2-dimensional array, it won't look like the usual visual representation of the matrix. You will see the transposed matrix.

There is just one scenario where it still confuses me a bit. Namely when we parse an image to a matrix of pixel values (or vice versa, when a matrix is rendered to an image). Here it would be sort of nice to have the points on the coordinate system match up with the coordinates in the matrix, but they are transposed. When I have a pixel value with matrix coordinate (100,100) and I go 100 pixels to the right on the image, the result is (100,200), not (200,100).