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
In mathematics, you denote the matrix entry in row
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
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
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)
.