What is the most rigorous definition of a matrix?

Let $I_n:=\{1,\cdots, n\}$.

A $n \times m$-matrix with coefficients in a ring $\mathcal{R}$ is a function $a: I_n \times I_m \to \mathcal{R}$. We define $a_{i,j}:=a(i,j)$.

In other words, a rectangular array.

Sidenote: In my point of view, I think it is particularly useful to see the above definition as a model for the concept of a matrix, and retain subconsciously the relevant idea of a rectangular array as the core concept. If you truly understand the core concept and has relative comfort with mathematics, coming up with the above definition is a simple matter.


Let $R$ be a commutative ring with identity, and $n,m$ be positive integers. The set of $n\times m$ matrices $R^{n\times m}$ is defined as an $R$-module (vector space, if $R$ is a field) freely generated by elements $\{e_{i,j}\}$, where $1\leq i \leq n$ and $1 \leq j \leq m$. The element $e_{i,j}$ represents the matrix with all entries equal to zero, except the entry in $i$-th row and $j$-th column, which is equal to one.

For example, for $n=5, m=6$

$$e_{2,4}=\begin{pmatrix}0&0&0&0&0&0\\0&0&0&1&0&0\\0&0&0&0&0&0\\0&0&0&0&0&0\\0&0&0&0&0&0\end{pmatrix}$$

Any matrix is a linear combination of $e_{i,j}$, with the coefficients being just the matrix entries.

This is still just an $n \times m$-dimensional $R$-module, but there is also a natural multiplication map $\times : R^{n\times m} \times R^{m \times p} \rightarrow R^{n \times p}$, defined by $$e_{i,j} \times e_{k,l} = \begin{cases} e_{i,l} & j = k \\ 0 & j \neq k \end{cases}$$ and extended by linearity. In fact, it is the standard matrix product.

In case $n=m$, this multiplication makes $R^{n\times n}$ into an $R$-algebra, isomorphic to the algebra of all endomorphisms on $R^n$.