🧮

Matrix Multiplication: Linear Algebra Study Notes

October 11, 2026

🧮 Matrix Multiplication

Main Topics Covered

  • Definition, size rule and notation of the matrix product
  • Matrix times matrix, matrix times vector, vector times matrix, vector times vector
  • Fundamental applications: linear maps, rotations, resource allocation, linear systems, bilinear forms
  • General properties: non-commutativity, distributivity, scalar product, transpose, conjugate, associativity
  • Computational cost of parenthesization and similarity transformations
  • Square matrices: ring structure, inverses, determinant, powers
  • Abstract algebra viewpoint
  • Computational complexity (Strassen and beyond)
  • Other types of matrix products

📌 Overview

Matrix multiplication is a binary operation that produces a matrix from two matrices. It is a basic tool of linear algebra.

  • The number of columns in the first matrix must equal the number of rows in the second matrix.
  • The resulting matrix, the matrix product, has the number of rows of the first and the number of columns of the second matrix.
  • The product of matrices A\mathbf{A} and B\mathbf{B} is denoted AB\mathbf{AB}.
  • It was first described by the French mathematician Jacques Philippe Marie Binet in 1812, to represent the composition of linear maps that are represented by matrices.
  • Applications span mathematics, applied mathematics, statistics, physics, economics and engineering.
  • Computing matrix products is a central operation in all computational applications of linear algebra.

🔤 Notation

  • Matrices: capital letters in bold, e.g. A\mathbf{A}.
  • Vectors: lowercase bold, e.g. a\mathbf{a}.
  • Entries of vectors and matrices: italic (numbers from a field), e.g. AA and aa.
  • Index notation is often the clearest way to express definitions. The entry in row ii, column jj of A\mathbf{A} is written (A)ij(\mathbf{A})_{ij}, AijA_{ij} or aija_{ij}.
  • A single subscript, e.g. A1,A2\mathbf{A}_1, \mathbf{A}_2, selects a matrix (not an entry) from a collection of matrices.

📐 Definitions

Matrix times matrix

Let A\mathbf{A} be an m×nm \times n matrix and B\mathbf{B} an n×pn \times p matrix:

A=(a11a12⋯a1na21a22⋯a2n⋮⋮⋱⋮am1am2⋯amn),B=(b11b12⋯b1pb21b22⋯b2p⋮⋮⋱⋮bn1bn2⋯bnp)\mathbf{A}=\begin{pmatrix}a_{11}&a_{12}&\cdots &a_{1n}\\a_{21}&a_{22}&\cdots &a_{2n}\\\vdots &\vdots &\ddots &\vdots \\a_{m1}&a_{m2}&\cdots &a_{mn}\end{pmatrix},\quad \mathbf{B}=\begin{pmatrix}b_{11}&b_{12}&\cdots &b_{1p}\\b_{21}&b_{22}&\cdots &b_{2p}\\\vdots &\vdots &\ddots &\vdots \\b_{n1}&b_{n2}&\cdots &b_{np}\end{pmatrix}

The product C=AB\mathbf{C}=\mathbf{AB} (written without multiplication signs or dots) is the m×pm \times p matrix

C=(c11c12⋯c1pc21c22⋯c2p⋮⋮⋱⋮cm1cm2⋯cmp)\mathbf{C}=\begin{pmatrix}c_{11}&c_{12}&\cdots &c_{1p}\\c_{21}&c_{22}&\cdots &c_{2p}\\\vdots &\vdots &\ddots &\vdots \\c_{m1}&c_{m2}&\cdots &c_{mp}\end{pmatrix}

such that

cij=ai1b1j+ai2b2j+⋯+ainbnj=∑k=1naikbkjc_{ij}=a_{i1}b_{1j}+a_{i2}b_{2j}+\cdots +a_{in}b_{nj}=\sum _{k=1}^{n}a_{ik}b_{kj}

for i=1,…,mi = 1, \ldots, m and j=1,…,pj = 1, \ldots, p.

  • Each entry cijc_{ij} is obtained by multiplying term by term the entries of the iith row of A\mathbf{A} and the jjth column of B\mathbf{B}, then summing these nn products.
  • In other words, cijc_{ij} is the dot product of the iith row of A\mathbf{A} and the jjth column of B\mathbf{B}.
  • Written out in full:

C=(a11b11+⋯+a1nbn1⋯a11b1p+⋯+a1nbnp⋮⋱⋮am1b11+⋯+amnbn1⋯am1b1p+⋯+amnbnp)\mathbf{C}=\begin{pmatrix}a_{11}b_{11}+\cdots +a_{1n}b_{n1}&\cdots &a_{11}b_{1p}+\cdots +a_{1n}b_{np}\\\vdots &\ddots &\vdots \\a_{m1}b_{11}+\cdots +a_{mn}b_{n1}&\cdots &a_{m1}b_{1p}+\cdots +a_{mn}b_{np}\end{pmatrix}

The product AB\mathbf{AB} is defined if and only if the number of columns in A\mathbf{A} equals the number of rows in B\mathbf{B}, in this case nn.

Entries need not be numbers. They may be any mathematical objects for which an addition and a multiplication are defined, that are associative, and such that the addition is commutative and the multiplication is distributive with respect to the addition. In particular, the entries may be matrices themselves (block matrix).

Matrix times vector

  • A vector x\mathbf{x} of size nn can be identified with an n×1n \times 1 column matrix X\mathbf{X}, with Xi1=xi\mathbf{X}_{i1}=\mathbf{x}_i.
  • For an m×nm \times n matrix A\mathbf{A}, the product Ax\mathbf{Ax} is a vector y\mathbf{y} of size mm (the m×1m \times 1 matrix AX\mathbf{AX}), with

yi=∑j=1naijxjy_i=\sum _{j=1}^{n}a_{ij}x_j

  • One way of looking at this is that the changes from "plain" vector to column vector and back are assumed and left implicit.

Vector times matrix

  • A vector x\mathbf{x} of size nn can also be identified with a 1×n1 \times n (row) matrix.
  • To make clear that a row vector is meant, it is customary to write it as the transpose of a column vector, as in xTA\mathbf{x}^{\mathrm{T}}\mathbf{A}.
  • Useful identity: xTA=(ATx)T\mathbf{x}^{\mathrm{T}}\mathbf{A}=(\mathbf{A}^{\mathrm{T}}\mathbf{x})^{\mathrm{T}}.
  • For an n×pn \times p matrix A\mathbf{A}, with xTA=yT\mathbf{x}^{\mathrm{T}}\mathbf{A}=\mathbf{y}^{\mathrm{T}}:

yk=∑j=1nxjajky_k=\sum _{j=1}^{n}x_ja_{jk}

Vector times vector

A vector with nn components can be represented as a 1×n1 \times n matrix (row vector) or an n×1n \times 1 matrix (column vector).

ProductFormResult
Dot (inner) product of column vectors a,b\mathbf{a}, \mathbf{b}aTb\mathbf{a}^{\mathrm{T}}\mathbf{b}a 1×11 \times 1 matrix
Outer productabT\mathbf{a}\mathbf{b}^{\mathrm{T}} (column times row)an n×nn \times n matrix

Illustration

Each entry of the product matrix corresponds to a row of A\mathbf{A} and a column of B\mathbf{B}. For a 4×24\times 2 matrix times a 2×32\times 3 matrix, giving a 4×34 \times 3 matrix, the highlighted entries are:

c12=a11b12+a12b22c33=a31b13+a32b23\begin{aligned}c_{12}&=a_{11}b_{12}+a_{12}b_{22}\\c_{33}&=a_{31}b_{13}+a_{32}b_{23}\end{aligned}

🛠️ Fundamental Applications

Matrix multiplication was introduced to facilitate and clarify computations in linear algebra. This relationship remains fundamental in mathematics, physics, chemistry, engineering and computer science.

Linear maps

  • If a vector space has a finite basis, each vector is uniquely represented by a finite sequence of scalars, its coordinate vector. These coordinate vectors form a vector space isomorphic to the original one.
  • A coordinate vector is commonly organized as a column matrix, so a column vector represents both a coordinate vector and a vector of the original space.
  • A linear map AA from a space of dimension nn into a space of dimension mm maps a column vector x\mathbf{x} onto the column vector

y=A(x)=(a11x1+⋯+a1nxn⋮am1x1+⋯+amnxn)\mathbf{y}=A(\mathbf{x})={\begin{pmatrix}a_{11}x_{1}+\cdots +a_{1n}x_{n}\\\vdots \\a_{m1}x_{1}+\cdots +a_{mn}x_{n}\end{pmatrix}}

  • The map is thus defined by the matrix A\mathbf{A} and maps x\mathbf{x} to y=Ax\mathbf{y}=\mathbf{Ax}.
  • If BB is another linear map into a space of dimension pp, it is represented by a p×mp\times m matrix B\mathbf{B}. The matrix of the composite map B∘AB\circ A is the matrix product BA\mathbf{BA}.
  • The definition of function composition, (B∘A)(x)=B(A(x))(B\circ A)(\mathbf{x})=B(A(\mathbf{x})), is here a specific case of associativity of the matrix product:

(BA)x=B(Ax)=BAx(\mathbf{BA})\mathbf{x}=\mathbf{B}(\mathbf{Ax})=\mathbf{BAx}

Geometric rotations

In a Cartesian coordinate system in a Euclidean plane, rotation by an angle α\alpha around the origin is a linear map. It maps a source point (x,y)(x, y) to its image (x′,y′)(x', y') by

[x′y′]=[cos⁡α−sin⁡αsin⁡αcos⁡α][xy]\begin{bmatrix}x'\\y'\end{bmatrix}=\begin{bmatrix}\cos \alpha &-\sin \alpha \\\sin \alpha &\cos \alpha \end{bmatrix}\begin{bmatrix}x\\y\end{bmatrix}

The composition of the rotation by α\alpha and the rotation by β\beta is:

[cos⁡β−sin⁡βsin⁡βcos⁡β][cos⁡α−sin⁡αsin⁡αcos⁡α]=[cos⁡(α+β)−sin⁡(α+β)sin⁡(α+β)cos⁡(α+β)]\begin{bmatrix}\cos \beta &-\sin \beta \\\sin \beta &\cos \beta \end{bmatrix}\begin{bmatrix}\cos \alpha &-\sin \alpha \\\sin \alpha &\cos \alpha \end{bmatrix}=\begin{bmatrix}\cos(\alpha +\beta )&-\sin(\alpha +\beta )\\\sin(\alpha +\beta )&\cos(\alpha +\beta )\end{bmatrix}

Trigonometric identities are used for the second equality. The composition corresponds to the rotation by angle α+β\alpha+\beta, as expected.

Resource allocation in economics

A fictitious factory uses 4 kinds of basic commodities b1,…,b4b_1,\ldots,b_4 to produce 3 kinds of intermediate goods m1,m2,m3m_1, m_2, m_3, which in turn are used to produce 3 kinds of final products f1,f2,f3f_1, f_2, f_3. The matrices

A=(101211011112),B=(121231422)\mathbf{A}=\begin{pmatrix}1&0&1\\2&1&1\\0&1&1\\1&1&2\end{pmatrix},\qquad \mathbf{B}=\begin{pmatrix}1&2&1\\2&3&1\\4&2&2\end{pmatrix}

give the amount of basic commodities needed per intermediate good, and the amount of intermediate goods needed per final product, respectively.

  • Example: to produce one unit of m1m_1, one unit of b1b_1, two units of b2b_2, no units of b3b_3 and one unit of b4b_4 are needed (the first column of A\mathbf{A}).
  • Multiplying gives the basic commodities needed per final good:

AB=(5438956531196)\mathbf{AB}=\begin{pmatrix}5&4&3\\8&9&5\\6&5&3\\11&9&6\end{pmatrix}

  • The bottom left entry is 1⋅1+1⋅2+2⋅4=111\cdot 1+1\cdot 2+2\cdot 4=11: 11 units of b4b_4 are needed to produce one unit of f1f_1. Indeed, one b4b_4 for m1m_1, one for each of two m2m_2, and 2 for each of four m3m_3 are needed for one f1f_1.
  • To produce 100 units of f1f_1, 80 of f2f_2 and 60 of f3f_3:

(AB)(1008060)=(1000182011802180)(\mathbf{AB})\begin{pmatrix}100\\80\\60\end{pmatrix}=\begin{pmatrix}1000\\1820\\1180\\2180\end{pmatrix}

That is, 1000 of b1b_1, 1820 of b2b_2, 1180 of b3b_3 and 2180 of b4b_4. The same AB\mathbf{AB} can be reused for other final-good amounts.

System of linear equations

The general form of a system of linear equations is

a11x1+⋯+a1nxn=b1,a21x1+⋯+a2nxn=b2,⋮am1x1+⋯+amnxn=bm\begin{matrix}a_{11}x_{1}+\cdots +a_{1n}x_{n}=b_{1},\\a_{21}x_{1}+\cdots +a_{2n}x_{n}=b_{2},\\\vdots \\a_{m1}x_{1}+\cdots +a_{mn}x_{n}=b_{m}\end{matrix}

With the notation above, such a system is equivalent to the single matrix equation Ax=b\mathbf{Ax}=\mathbf{b}.

Dot product, bilinear form and sesquilinear form

  • The dot product of two column vectors is the unique entry of the matrix product xTy\mathbf{x}^{\mathsf{T}}\mathbf{y} (a 1×11\times1 matrix is identified with its unique entry).
  • Any bilinear form over a finite-dimensional vector space may be expressed as the matrix product xTAy\mathbf{x}^{\mathsf{T}}\mathbf{Ay}.
  • Any sesquilinear form may be expressed as x†Ay\mathbf{x}^{\dagger}\mathbf{Ay}, where x†\mathbf{x}^{\dagger} is the conjugate transpose of x\mathbf{x} (conjugate of the transpose, or equivalently transpose of the conjugate).

⚖️ General Properties

Matrix multiplication shares some properties with usual multiplication. However, it is not defined if the number of columns of the first factor differs from the number of rows of the second, and it is non-commutative, even when the product remains defined after changing the order of the factors.

Non-commutativity

An operation is commutative if, given two elements A\mathbf{A} and B\mathbf{B} such that AB\mathbf{AB} and BA\mathbf{BA} are defined, AB=BA\mathbf{AB}=\mathbf{BA}.

For A\mathbf{A} of size m×nm\times n and B\mathbf{B} of size p×qp\times q:

  • AB\mathbf{AB} is defined iff n=pn=p; BA\mathbf{BA} is defined iff m=qm=q. If one product is defined, the other need not be.
  • If m=q≠n=pm=q\neq n=p, both are defined but have different sizes, so they cannot be equal.
  • Only if m=q=n=pm=q=n=p (square matrices of the same size) are both products defined and of the same size. Even then, in general AB≠BA\mathbf{AB}\neq\mathbf{BA}.

Example:

(0100)(0010)=(1000)but(0010)(0100)=(0001)\begin{pmatrix}0&1\\0&0\end{pmatrix}\begin{pmatrix}0&0\\1&0\end{pmatrix}=\begin{pmatrix}1&0\\0&0\end{pmatrix}\quad\text{but}\quad\begin{pmatrix}0&0\\1&0\end{pmatrix}\begin{pmatrix}0&1\\0&0\end{pmatrix}=\begin{pmatrix}0&0\\0&1\end{pmatrix}

  • This can be expanded to show: for an n×nn\times n matrix A\mathbf{A} over a field FF, AB=BA\mathbf{AB}=\mathbf{BA} for every n×nn\times n matrix B\mathbf{B} over FF if and only if A=c I\mathbf{A}=c\,\mathbf{I} with c∈Fc\in F, where I\mathbf{I} is the n×nn\times n identity matrix.
  • Over a ring instead of a field, one must add the condition that cc belongs to the center of the ring.
  • A special case where commutativity does occur: two square diagonal matrices D\mathbf{D} and E\mathbf{E} of the same size satisfy DE=ED\mathbf{DE}=\mathbf{ED} (over a general ring, corresponding entries must also commute).

Distributivity

The product is distributive with respect to matrix addition. For matrices of sizes m×nm\times n, n×pn\times p, n×pn\times p and p×qp\times q (call them A,B,C,D\mathbf{A},\mathbf{B},\mathbf{C},\mathbf{D}):

  • Left distributivity: A(B+C)=AB+AC\mathbf{A}(\mathbf{B}+\mathbf{C})=\mathbf{AB}+\mathbf{AC}
  • Right distributivity: (B+C)D=BD+CD(\mathbf{B}+\mathbf{C})\mathbf{D}=\mathbf{BD}+\mathbf{CD}

These follow from distributivity for coefficients:

∑kaik(bkj+ckj)=∑kaikbkj+∑kaikckj\sum _{k}a_{ik}(b_{kj}+c_{kj})=\sum _{k}a_{ik}b_{kj}+\sum _{k}a_{ik}c_{kj}

Product with a scalar

  • For a matrix A\mathbf{A} and scalar cc, cAc\mathbf{A} and Ac\mathbf{A}c are obtained by left or right multiplying all entries of A\mathbf{A} by cc. If scalars commute, cA=Acc\mathbf{A}=\mathbf{A}c.
  • If AB\mathbf{AB} is defined, then c(AB)=(cA)Bc(\mathbf{AB})=(c\mathbf{A})\mathbf{B} and (AB)c=A(Bc)(\mathbf{AB})c=\mathbf{A}(\mathbf{B}c).
  • If scalars commute, all four matrices are equal. More generally, all four are equal if cc belongs to the center of a ring containing the entries, because then cX=Xcc\mathbf{X}=\mathbf{X}c for all matrices X\mathbf{X}.
  • These properties result from the bilinearity of the product of scalars:

c(∑kaikbkj)=∑k(caik)bkjc\left(\sum _{k}a_{ik}b_{kj}\right)=\sum _{k}(ca_{ik})b_{kj}

Transpose

If scalars commute, the transpose of a product is the product, in reverse order, of the transposes of the factors:

(AB)T=BTAT(\mathbf{AB})^{\mathsf{T}}=\mathbf{B}^{\mathsf{T}}\mathbf{A}^{\mathsf{T}}

where T denotes the interchange of rows and columns. This identity does not hold for noncommutative entries, since the order between the entries of A\mathbf{A} and B\mathbf{B} is reversed when the definition is expanded.

Complex conjugate

If A\mathbf{A} and B\mathbf{B} have complex entries, then

(AB)∗=A∗B∗(\mathbf{AB})^{*}=\mathbf{A}^{*}\mathbf{B}^{*}

where ∗* denotes the entry-wise complex conjugate. This follows because the conjugate of a sum is the sum of the conjugates and the conjugate of a product is the product of the conjugates.

Transposition acts on the indices of the entries, while conjugation acts independently on the entries themselves. Hence

(AB)†=B†A†(\mathbf{AB})^{\dagger}=\mathbf{B}^{\dagger}\mathbf{A}^{\dagger}

where †\dagger denotes the conjugate transpose.

Associativity

Given three matrices, (AB)C(\mathbf{AB})\mathbf{C} and A(BC)\mathbf{A}(\mathbf{BC}) are defined iff the columns of A\mathbf{A} equal the rows of B\mathbf{B} and the columns of B\mathbf{B} equal the rows of C\mathbf{C} (so if one product is defined, so is the other). Then:

(AB)C=A(BC)(\mathbf{AB})\mathbf{C}=\mathbf{A}(\mathbf{BC})

  • Parentheses can be omitted, writing ABC\mathbf{ABC}.
  • This extends to any number of matrices with matching dimensions: if the columns of Ai\mathbf{A}_i equal the rows of Ai+1\mathbf{A}_{i+1} for i=1,…,n−1i=1,\ldots,n-1, then

∏i=1nAi=A1A2⋯An\prod _{i=1}^{n}\mathbf{A}_i=\mathbf{A}_1\mathbf{A}_2\cdots \mathbf{A}_n

is defined and does not depend on the order of the multiplications, if the order of the matrices is kept fixed.

  • These properties may be proved by straightforward but complicated summation manipulations. The result also follows from the fact that matrices represent linear maps, so associativity of matrices is a specific case of associativity of function composition.

Computational complexity depends on parenthesization

The result does not depend on the order of operation, but the computational complexity may depend dramatically on it.

Example: for A,B,C\mathbf{A},\mathbf{B},\mathbf{C} of sizes 10×3010\times30, 30×530\times5, 5×605\times60:

OrderMultiplications needed
(AB)C(\mathbf{AB})\mathbf{C}10×30×5+10×5×60=4,50010\times30\times5 + 10\times5\times60 = 4{,}500
A(BC)\mathbf{A}(\mathbf{BC})30×5×60+10×30×60=27,00030\times5\times60 + 10\times30\times60 = 27{,}000

Algorithms exist for choosing the best order of products (matrix chain multiplication). As the number nn of matrices increases, the choice of the best order has been shown to have a complexity of O(nlog⁡n)O(n\log n).

Application to similarity

Any invertible matrix P\mathbf{P} defines a similarity transformation on square matrices of the same size:

SP(A)=P−1APS_{\mathbf{P}}(\mathbf{A})=\mathbf{P}^{-1}\mathbf{A}\mathbf{P}

Similarity transformations map products to products: SP(AB)=SP(A)SP(B)S_{\mathbf{P}}(\mathbf{AB})=S_{\mathbf{P}}(\mathbf{A})S_{\mathbf{P}}(\mathbf{B}). Indeed,

P−1(AB)P=P−1A(PP−1)BP=(P−1AP)(P−1BP)\mathbf{P}^{-1}(\mathbf{AB})\mathbf{P}=\mathbf{P}^{-1}\mathbf{A}(\mathbf{P}\mathbf{P}^{-1})\mathbf{B}\mathbf{P}=(\mathbf{P}^{-1}\mathbf{A}\mathbf{P})(\mathbf{P}^{-1}\mathbf{B}\mathbf{P})

⬛ Square Matrices

Let Mn(R)\mathcal{M}_n(R) denote the set of n×nn\times n square matrices with entries in a ring RR (in practice often a field).

  • The product is defined for every pair of matrices in Mn(R)\mathcal{M}_n(R), making it a ring with the identity matrix I\mathbf{I} (diagonal entries 1, all others 0) as identity element. It is also an associative RR-algebra.
  • If n>1n>1, many matrices have no multiplicative inverse. For example, a matrix with a row (or column) of all zeros has no inverse.
  • If it exists, the inverse of A\mathbf{A} is denoted A−1\mathbf{A}^{-1} and satisfies

AA−1=A−1A=I\mathbf{A}\mathbf{A}^{-1}=\mathbf{A}^{-1}\mathbf{A}=\mathbf{I}

  • A matrix with an inverse is invertible; otherwise it is singular.
  • A product of matrices is invertible iff each factor is invertible, and then (AB)−1=B−1A−1(\mathbf{AB})^{-1}=\mathbf{B}^{-1}\mathbf{A}^{-1}.
  • When RR is commutative (in particular a field), the determinant of a product is the product of the determinants:

det⁡(AB)=det⁡(BA)=det⁡(A)det⁡(B)\det(\mathbf{AB})=\det(\mathbf{BA})=\det(\mathbf{A})\det(\mathbf{B})

  • Other matrix invariants behave less well with products. Still, if RR is commutative, AB\mathbf{AB} and BA\mathbf{BA} have the same trace, the same characteristic polynomial, and the same eigenvalues with the same multiplicities. The eigenvectors are generally different if AB≠BA\mathbf{AB}\neq\mathbf{BA}.

Powers of a matrix

A square matrix can be raised to any nonnegative integer power by repeated multiplication:

A0=I,A1=A,Ak=AA⋯A⏟k times\mathbf{A}^0=\mathbf{I},\qquad \mathbf{A}^1=\mathbf{A},\qquad \mathbf{A}^k=\underbrace{\mathbf{A}\mathbf{A}\cdots \mathbf{A}}_{k\text{ times}}

  • The trivial algorithm (repeated multiplication) needs k−1k-1 times the cost of a single matrix multiplication.
  • Exponentiation by squaring requires fewer than 2log⁡2k2\log_2 k matrix multiplications, and is much more efficient.
  • Easy case, a diagonal matrix: the product of diagonal matrices just multiplies corresponding diagonal elements, so the kkth power raises each entry to the power kk:

[a110⋯00a22⋯0⋮⋮⋱⋮00⋯ann]k=[a11k0⋯00a22k⋯0⋮⋮⋱⋮00⋯annk]\begin{bmatrix}a_{11}&0&\cdots &0\\0&a_{22}&\cdots &0\\\vdots &\vdots &\ddots &\vdots \\0&0&\cdots &a_{nn}\end{bmatrix}^{k}=\begin{bmatrix}a_{11}^{k}&0&\cdots &0\\0&a_{22}^{k}&\cdots &0\\\vdots &\vdots &\ddots &\vdots \\0&0&\cdots &a_{nn}^{k}\end{bmatrix}

🧩 Abstract Algebra

  • The definition of the matrix product requires that entries belong to a semiring, and does not require multiplication of the semiring's elements to be commutative.
  • Often entries belong to a field; the tropical semiring is also a common choice for graph shortest path problems.
  • Even over fields, the product is not commutative in general, although it is associative and distributive over matrix addition.
  • Identity matrices (zero outside the main diagonal, 1 on it) are identity elements of the matrix product. So n×nn\times n matrices over a ring form a ring, which is noncommutative except if n=1n=1 and the ground ring is commutative.
  • Over a commutative ring RR, a matrix has an inverse iff its determinant has a multiplicative inverse in RR. The determinant of a product of square matrices is the product of the determinants.
  • The n×nn\times n invertible matrices form a group under matrix multiplication; its subgroups are called matrix groups. Many classical groups (including all finite groups) are isomorphic to matrix groups, the starting point of group representation theory.
  • Matrices are the morphisms of a category, the category of matrices. Objects are the natural numbers measuring matrix size; composition of morphisms is matrix multiplication. The source of a morphism is the number of columns, and the target is the number of rows.

⏱️ Computational Complexity

  • The algorithm that follows the definition needs, in the worst case, n3n^3 multiplications and (n−1)n2(n-1)n^2 additions of scalars to multiply two n×nn\times n matrices. Its complexity is therefore O(n3)O(n^3), in a model where scalar operations take constant time.
  • Surprisingly, this is not optimal: in 1969 Volker Strassen gave an algorithm (Strassen's algorithm) with complexity

O(nlog⁡27)≈O(n2.8074)O(n^{\log _{2}7})\approx O(n^{2.8074})

  • Strassen's algorithm can be parallelized to further improve performance.
  • As of January 2024, the best peer-reviewed algorithm, by Virginia Vassilevska Williams, Yinzhan Xu, Zixuan Xu and Renfei Zhou, has complexity O(n2.371552)O(n^{2.371552}).
  • It is not known whether matrix multiplication can be done in n2+o(1)n^{2+o(1)} time. That would be optimal, since one must read the n2n^2 elements of a matrix to multiply it with another.
  • Because matrix multiplication underlies many algorithms, and many matrix operations have the same complexity up to a multiplicative constant, its complexity appears throughout numerical linear algebra and theoretical computer science.

🔗 Generalizations

Other types of products of matrices:

ProductDescription
Block matrix operationsOperations on matrices whose entries are matrices
Cracovian productA∧B=BTA\mathbf{A}\wedge\mathbf{B}=\mathbf{B}^{\mathsf{T}}\mathbf{A}
Frobenius inner productDot product of matrices considered as vectors; equivalently the sum of the entries of the Hadamard product
Hadamard productEntry-by-entry product of two matrices of the same size, giving a matrix of the same size
Kronecker (tensor) productGeneralization of the preceding to any size
Khatri-Rao product, face-splitting productFurther matrix products
Outer product (dyadic or tensor product)Of two column matrices: abT\mathbf{a}\mathbf{b}^{\mathsf{T}}
Scalar multiplicationMultiplying every entry by a scalar