Matrix Operations
Matrices add and scale entrywise, but their product is defined so that multiplication corresponds to composition of linear maps: the columns of AB are A applied to the columns of B. From that requirement follow the row-column rule, the algebra of products (associative and distributive but not commutative), powers, and the transpose.
╌╌╌╌
A linear transformation is stored as a matrix; composing two such maps produces a third, and matrix multiplication is the arithmetic that computes its matrix. The single requirement fixes every rule that follows: why the product is defined column by column, why it is associative but not commutative, and why its size constraints are what they are. Addition and scalar multiplication are the entrywise operations carried over from vectors.
Notation and entries
An matrix has rows and columns. The scalar in row and column is the -entry , and . Each column is a vector in , so writing the columns as gives
Several kinds of matrix recur often enough to name:
- Diagonal entries: the entries ; together they form the main diagonal.
- Diagonal matrix: a square matrix whose off-diagonal entries are all zero.
- Identity matrix : the diagonal matrix with s on the diagonal, so for every in .
- Zero matrix : every entry zero; its size is read from context.
Sums and scalar multiples
Two matrices are equal when they have the same size and the same corresponding entries. If and are both , the sum is the matrix formed by adding corresponding entries; is undefined when the sizes differ. For a scalar , the scalar multiple multiplies every entry by , and means , with .
For example, with
we get and , so .
Because addition and scaling reduce to the corresponding operations on the column vectors, matrices inherit all the familiar algebraic laws.1
Multiplication as composition
Multiplying a vector by produces ; multiplying that in turn by produces . The composite map is again linear, and the product is defined to be its matrix, so that
To turn this into a formula, take with columns and expand . Linearity of multiplication by gives
The bracketed matrix is the product we set out to build.
Two consequences of the definition:
- The number of columns of must equal the number of rows of (the
inner
dimensions match), or is undefined. - has as many rows as and as many columns as (the
outer
dimensions).
For example, if is and is , then is , while is undefined because the columns of do not match the rows of .
The row-column rule
The column definition is right for theory, but individual entries are computed faster by pairing a row of with a column of .
The entry in position is the dot product of row of with column of . A related identity records what a whole row of the product is: .
The algebra of products
Because matrix multiplication is composition of functions, and composition of functions is associative, products obey the same grouping and distribution rules as ordinary arithmetic, with one omission: commutativity.2
Associativity lets parentheses move freely, so a product is unambiguous as long as the left-to-right order is preserved. That order is where matrix algebra departs from scalar algebra.
Non-commutativity is visible in the columns: the columns of are combinations of the columns of , whereas the columns of are built from the columns of , so the two products describe different maps. When does hold, and are said to commute.
Powers
For a square matrix and a positive integer , the power is the product of copies of :
Setting keeps meaning apply to a total of times,
with zero applications leaving unchanged. Powers of matrices drive the
Leontief model,
Markov chains, and the study of
eigenvalues, where a
good factorization of turns into something computable.
The transpose
Rows and columns exchange roles under the transpose.
The transpose interacts with the other operations through four rules; the last reverses the order of a product.3
In words, the transpose of a product is the product of the transposes in reverse order, and this extends to any number of factors: . In general , even when the right side happens to be defined.
Inner and outer products
Viewing a vector in as an matrix turns two special transpose products into familiar objects. For :
- Inner product : a matrix, written as the single real number . This is the dot product that underlies length and orthogonality.
- Outer product : an matrix whose -entry is . Outer products reappear as the rank-one pieces of block multiplication and the SVD.
| Operation | Requirement | Result size | Reads as |
|---|---|---|---|
| same size | entrywise sum | ||
| any | entrywise scale | ||
| cols = rows | composition of maps | ||
| any | reflect across diagonal | ||
| same length | scalar (dot product) | ||
| any lengths | rank-one matrix |
Numerical note
High-performance libraries such as LAPACK compute one column at a time, in agreement with the column definition, because that layout matches how matrices are stored in memory and because the columns of can be assigned to separate processors and computed in parallel. The order of a chained product also matters for cost, not just correctness: when is square and has few columns, computing can be far cheaper than , even though the two agree by associativity. The LU factorization turns these observations into a systematic way to solve many systems at once.
Footnotes
- Lay, Linear Algebra and Its Applications, §2.1 — Theorem 1: the commutative, associative, and distributive laws for matrix sums and scalar multiples, each verified column by column from the vector case. ↩
- Lay, §2.1 — Theorem 2: associativity of multiplication follows from associativity of function composition, together with the two distributive laws, , and ; the accompanying warnings collect the three ways matrix algebra differs from scalar algebra. ↩
- Lay, §2.1 — Theorem 3 and the definition of the transpose, including and the inner/outer product interpretations of and . ↩
╌╌ END ╌╌