Matrix multiplication
In mathematics, specifically in linear algebra, matrix multiplication is a binary operation that produces a matrix from two matrices. For matrix multiplication, the number of columns in the first matrix must be equal to the number of rows in the second matrix. The resulting matrix, known as the matrix product, has the number of rows of the first and the number of columns of the second matrix. The product of matrices and is denoted as.
Matrix multiplication 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. Matrix multiplication is thus a basic tool of linear algebra, and as such has numerous applications in many areas of mathematics, as well as in applied mathematics, statistics, physics, economics, and engineering.
Computing matrix products is a central operation in all computational applications of linear algebra.
Notation
This article will use the following notational conventions: matrices are represented by capital letters in bold, e.g. ; vectors in lowercase bold, e.g. ; and entries of vectors and matrices are italic, e.g. and. Index notation is often the clearest way to express definitions, and is used as standard in the literature. The entry in row, column of matrix is indicated by, or. In contrast, a single subscript, e.g., is used to select a matrix from a collection of matrices.Definitions
Matrix times matrix
If is an matrix and is an matrix,the matrix product is defined to be the matrix
such that
for and.
That is, the entry of the product is obtained by multiplying term-by-term the entries of the th row of and the th column of, and summing these products. In other words, is the dot product of the th row of and the th column of.
Therefore, can also be written as
Thus the product is defined if and only if the number of columns in equals the number of rows in, in this case.
In most scenarios, the entries are numbers, but they may be any kind of 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.
Matrix times vector
A vector of length can be viewed as a column vector, corresponding to an matrix whose entries are given by If is an matrix, the matrix-times-vector product denoted by is then the vector that, viewed as a column vector, is equal to the matrix In index notation, this amounts to: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
Similarly, a vector of length can be viewed as a row vector, corresponding to a matrix. To make it clear that a row vector is meant, it is customary in this context to represent it as the transpose of a column vector; thus, one will see notations such as The identity holds. In index notation, if is an matrix, amounts to:Vector times vector
A vector with n components can be represented as a matrix or as a matrix.Assuming that and are both column-vectors the dot product is equal to the single entry of the matrix resulting from the matrix multiplication of the row-vector with the column-vector, i.e..
The matrix multiplication between the column-vector and the row-vector, also known as outer-product, will, instead, give a matrix.
Illustration
The figure to the right illustrates diagrammatically the product of two matrices and, showing how each intersection in the product matrix corresponds to a row of and a column of.The values at the intersections, marked with circles in figure to the right, are:
Fundamental applications
Historically, matrix multiplication has been introduced for facilitating and clarifying computations in linear algebra. This strong relationship between matrix multiplication and linear algebra remains fundamental in all mathematics, as well as in physics, chemistry, engineering and computer science.Linear maps
If a vector space has a finite basis, its vectors are each uniquely represented by a finite sequence of scalars, called a coordinate vector, whose elements are the coordinates of the vector on the basis. These coordinate vectors form another vector space, which is isomorphic to the original vector space. A coordinate vector is commonly organized as a column matrix, which is a matrix with only one column. So, a column vector represents both a coordinate vector, and a vector of the original vector space.A linear map from a vector space of dimension into a vector space of dimension maps a column vector
onto the column vector
The linear map is thus defined by the matrix
and maps the column vector to the matrix product
If is another linear map from the preceding vector space of dimension, into a vector space of dimension, it is represented by a matrix A straightforward computation shows that the matrix of the composite map is the matrix product The general formula ) that defines the function composition is instanced here as a specific case of associativity of matrix product :
Geometric rotations
Using a Cartesian coordinate system in a Euclidean plane, the rotation by an angle around the origin is a linear map.More precisely,
where the source point and its image are written as column vectors.
The composition of the rotation by and that by then corresponds to the matrix product
where appropriate trigonometric identities are employed for the second equality.
That is, the composition corresponds to the rotation by angle, as expected.
Resource allocation in economics
As an example, a fictitious factory uses 4 kinds of basic commodities, to produce 3 kinds of intermediate goods,, which in turn are used to produce 3 kinds of final products,. The matricesprovide the amount of basic commodities needed for a given amount of intermediate goods, and the amount of intermediate goods needed for a given amount of final products, respectively.
For example, to produce one unit of intermediate good, one unit of basic commodity, two units of, no units of, and one unit of are needed, corresponding to the first column of.
Using matrix multiplication, compute
this matrix directly provides the amounts of basic commodities needed for given amounts of final goods. For example, the bottom left entry of is computed as, reflecting that units of are needed to produce one unit of. Indeed, one unit is needed for, one for each of two, and for each of the four units that go into the unit, see picture.
In order to produce e.g. 100 units of the final product, 80 units of, and 60 units of, the necessary amounts of basic goods can be computed as
that is, units of, units of, units of, units of are needed.
Similarly, the product matrix can be used to compute the needed amounts of basic goods for other final-good amount data.
System of linear equations
The general form of a system of linear equations isUsing same notation as above, such a system is equivalent with the single matrix equation
Dot product, bilinear form and sesquilinear form
The dot product of two column vectors is the unique entry of the matrix productwhere is the row vector obtained by transposing.
More generally, any bilinear form over a vector space of finite dimension may be expressed as a matrix product
and any sesquilinear form may be expressed as
where denotes the conjugate transpose of .
General properties
Matrix multiplication shares some properties with usual multiplication. However, matrix multiplication is not defined if the number of columns of the first factor differs from the number of rows of the second factor, 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 and such that the product is defined, then is also defined, andIf and are matrices of respective sizes and, then is defined if, and is defined if. Therefore, if one of the products is defined, the other one need not be defined. If, the two products are defined, but have different sizes; thus they cannot be equal. Only if, that is, if and are square matrices of the same size, are both products defined and of the same size. Even in this case, one has in general
For example
but
This example may be expanded for showing that, if is a matrix with entries in a field, then for every matrix with entries in, if and only if where, and is the identity matrix. If, instead of a field, the entries are supposed to belong to a ring, then one must add the condition that belongs to the center of the ring.
One special case where commutativity does occur is when and are two diagonal matrices ; then. Again, if the matrices are over a general ring rather than a field, the corresponding entries in each must also commute with each other for this to hold.
Distributivity
The matrix product is distributive with respect to matrix addition. That is, if are matrices of respective sizes,, , and, respectively, one hasand
This results from the distributivity for coefficients by
Product with a scalar
If is a matrix and a scalar, then the matrices and are obtained by left or right multiplying all entries of by. If the scalars have the commutative property, thenIf the product is defined, then
If the scalars have the commutative property, then all four matrices are equal. More generally, all four are equal if belongs to the center of a ring containing the entries of the matrices, because in this case, for all matrices.
These properties result from the bilinearity of the product of scalars:
Transpose
If the scalars have the commutative property, the transpose of a product of matrices is the product, in the reverse order, of the transposes of the factors. That iswhere T denotes the transpose, that is the interchange of rows and columns.
This identity does not hold for noncommutative entries, since the order between the entries of and is reversed, when one expands the definition of the matrix product.