---
tag: 0N1MY1T0W9
kind: definition
name: Matrix
msc: [15A99]
defines: 0VD9ZSWWJG
sources:
  - url: https://en.wikipedia.org/wiki/Matrix_(mathematics)
    locator: lead section
---

## Definition

Let $R$ be a ring, for example a field, and let $m, n \ge 0$ be integers.
An $m \times n$ *matrix* over $R$ is a family $A = (a_{ij})$ of elements $a_{ij} \in R$, indexed by the pairs $(i, j)$ with $1 \le i \le m$ and $1 \le j \le n$.
The element $a_{ij}$ is the *entry* of $A$ in row $i$ and column $j$.
The notation for $A$ is a rectangular array with $m$ rows and $n$ columns:
$$A = \begin{pmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{m1} & \cdots & a_{mn} \end{pmatrix}.$$
The set of all $m \times n$ matrices over $R$ is written $M_{m \times n}(R)$ or $R^{m \times n}$.

## Remarks

Two matrices are equal when they have the same size and the same entries in each position.
A $1 \times n$ matrix is a *row vector*, and an $m \times 1$ matrix is a *column vector*.
Mathlib uses arbitrary finite index types in place of $\{1, \dots, m\}$ and $\{1, \dots, n\}$.

## Explanations

### L1 human

A matrix is a table of numbers with a fixed number of rows and columns.
The matrix $\begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix}$ has 2 rows and 3 columns, so it is a $2 \times 3$ matrix.
We name an entry by its row first and then its column.
