Matrix Multiplication
   HOME

TheInfoList



OR:

In
mathematics Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, specifically in
linear algebra Linear algebra is the branch of mathematics concerning linear equations such as :a_1x_1+\cdots +a_nx_n=b, linear maps such as :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and through matrix (mathemat ...
, matrix multiplication is a
binary operation In mathematics, a binary operation or dyadic operation is a rule for combining two elements (called operands) to produce another element. More formally, a binary operation is an operation of arity two. More specifically, a binary operation ...
that produces a
matrix Matrix (: matrices or matrixes) or MATRIX may refer to: Science and mathematics * Matrix (mathematics), a rectangular array of numbers, symbols or expressions * Matrix (logic), part of a formula in prenex normal form * Matrix (biology), the m ...
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 Composition or Compositions may refer to: Arts and literature *Composition (dance), practice and teaching of choreography * Composition (language), in literature and rhetoric, producing a work in spoken tradition and written discourse, to include ...
of
linear map In mathematics, and more specifically in linear algebra, a linear map (also called a linear mapping, linear transformation, vector space homomorphism, or in some contexts linear function) is a mapping V \to W between two vector spaces that p ...
s that are represented by matrices. Matrix multiplication is thus a basic tool of
linear algebra Linear algebra is the branch of mathematics concerning linear equations such as :a_1x_1+\cdots +a_nx_n=b, linear maps such as :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and through matrix (mathemat ...
, and as such has numerous applications in many areas of mathematics, as well as in
applied mathematics Applied mathematics is the application of mathematics, mathematical methods by different fields such as physics, engineering, medicine, biology, finance, business, computer science, and Industrial sector, industry. Thus, applied mathematics is a ...
,
statistics Statistics (from German language, German: ', "description of a State (polity), state, a country") is the discipline that concerns the collection, organization, analysis, interpretation, and presentation of data. In applying statistics to a s ...
,
physics Physics is the scientific study of matter, its Elementary particle, fundamental constituents, its motion and behavior through space and time, and the related entities of energy and force. "Physical science is that department of knowledge whi ...
,
economics Economics () is a behavioral science that studies the Production (economics), production, distribution (economics), distribution, and Consumption (economics), consumption of goods and services. Economics focuses on the behaviour and interac ...
, and
engineering Engineering is the practice of using natural science, mathematics, and the engineering design process to Problem solving#Engineering, solve problems within technology, increase efficiency and productivity, and improve Systems engineering, s ...
. 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 (they are numbers from a field), e.g. and .
Index notation In mathematics and computer programming, index notation is used to specify the elements of an array of numbers. The formalism of how indices are used varies according to the subject. In particular, there are different methods for referring to th ...
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 (not a matrix entry) from a collection of matrices.


Definitions


Matrix times matrix

If is an matrix and is an matrix, \mathbf=\begin a_ & a_ & \cdots & a_ \\ a_ & a_ & \cdots & a_ \\ \vdots & \vdots & \ddots & \vdots \\ a_ & a_ & \cdots & a_ \\ \end,\quad\mathbf=\begin b_ & b_ & \cdots & b_ \\ b_ & b_ & \cdots & b_ \\ \vdots & \vdots & \ddots & \vdots \\ b_ & b_ & \cdots & b_ \\ \end the ''matrix product'' (denoted without multiplication signs or dots) is defined to be the matrix \mathbf = \begin c_ & c_ & \cdots & c_ \\ c_ & c_ & \cdots & c_ \\ \vdots & \vdots & \ddots & \vdots \\ c_ & c_ & \cdots & c_ \\ \end such that c_ = a_ b_ + a_ b_ + \cdots + a_ b_ = \sum_^n a_ b_, 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 In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a Scalar (mathematics), scalar as a result". It is also used for other symmetric bilinear forms, for example in a pseudo-Euclidean space. N ...
of the th row of and the th column of . Therefore, can also be written as \mathbf = \begin a_b_ +\cdots + a_b_ & a_b_ +\cdots + a_b_ & \cdots & a_b_ +\cdots + a_b_ \\ a_b_ +\cdots + a_b_ & a_b_ +\cdots + a_b_ & \cdots & a_b_ +\cdots + a_b_ \\ \vdots & \vdots & \ddots & \vdots \\ a_b_ +\cdots + a_b_ & a_b_ +\cdots + a_b_ & \cdots & a_b_ +\cdots + a_b_ \\ \end 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 object A mathematical object is an abstract concept arising in mathematics. Typically, a mathematical object can be a value that can be assigned to a Glossary of mathematical symbols, symbol, and therefore can be involved in formulas. Commonly encounter ...
s for which an addition and a multiplication are defined, that are
associative In mathematics, the associative property is a property of some binary operations that rearranging the parentheses in an expression will not change the result. In propositional logic, associativity is a valid rule of replacement for express ...
, and such that the addition is
commutative In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Perhaps most familiar as a pr ...
, and the multiplication is distributive with respect to the addition. In particular, the entries may be matrices themselves (see
block matrix In mathematics, a block matrix or a partitioned matrix is a matrix that is interpreted as having been broken into sections called blocks or submatrices. Intuitively, a matrix interpreted as a block matrix can be visualized as the original matrix w ...
).


Matrix times vector

A vector \mathbf x of length n can be viewed as a
column vector In linear algebra, a column vector with elements is an m \times 1 matrix consisting of a single column of entries, for example, \boldsymbol = \begin x_1 \\ x_2 \\ \vdots \\ x_m \end. Similarly, a row vector is a 1 \times n matrix for some , c ...
, corresponding to an n\times1 matrix \mathbf X whose entries are given by \mathbf X_=\mathbf x_i. If \mathbf A is an m\times n matrix, the matrix-times-vector product denoted by \mathbf is then the vector \mathbf y that, viewed as a column vector, is equal to the m\times1 matrix \mathbf. In index notation, this amounts to: :y_i=\sum_^n a_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

Similarly, a vector \mathbf x of length n can be viewed as a
row vector In linear algebra, a column vector with elements is an m \times 1 matrix consisting of a single column of entries, for example, \boldsymbol = \begin x_1 \\ x_2 \\ \vdots \\ x_m \end. Similarly, a row vector is a 1 \times n matrix for some , co ...
, corresponding to a 1\times n matrix. To make it clear that a row vector is meant, it is customary in this context to represent it as the
transpose In linear algebra, the transpose of a Matrix (mathematics), matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix by producing another matrix, often denoted by (among other ...
of a column vector; thus, one will see notations such as \mathbf^\mathrm\mathbf. The identity \mathbf^\mathrm\mathbf=(\mathbf^\mathrm\mathbf)^\mathrm holds. In index notation, if \mathbf A is an n\times p matrix, \mathbf^\mathrm\mathbf=\mathbf^\mathrm amounts to: y_k=\sum_^n x_j a_.


Vector times vector

The
dot product In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a Scalar (mathematics), scalar as a result". It is also used for other symmetric bilinear forms, for example in a pseudo-Euclidean space. N ...
\mathbf a\cdot\mathbf b of two vectors \mathbf a and \mathbf b of equal length is equal to the single entry of the 1\times 1 matrix resulting from multiplying these vectors as a row and a column vector, thus: \mathbf^\mathrm\mathbf (or \mathbf^\mathrm\mathbf, which results in the same 1\times 1 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 . \overset \overset = \overset The values at the intersections, marked with circles in figure to the right, are: \begin c_ & = a_ b_ + a_ b_ \\ c_ & = a_ b_ + a_ b_ . \end


Fundamental applications

Historically, matrix multiplication has been introduced for facilitating and clarifying computations in
linear algebra Linear algebra is the branch of mathematics concerning linear equations such as :a_1x_1+\cdots +a_nx_n=b, linear maps such as :(x_1, \ldots, x_n) \mapsto a_1x_1+\cdots +a_nx_n, and their representations in vector spaces and through matrix (mathemat ...
. This strong relationship between matrix multiplication and linear algebra remains fundamental in all mathematics, as well as in
physics Physics is the scientific study of matter, its Elementary particle, fundamental constituents, its motion and behavior through space and time, and the related entities of energy and force. "Physical science is that department of knowledge whi ...
,
chemistry Chemistry is the scientific study of the properties and behavior of matter. It is a physical science within the natural sciences that studies the chemical elements that make up matter and chemical compound, compounds made of atoms, molecules a ...
,
engineering Engineering is the practice of using natural science, mathematics, and the engineering design process to Problem solving#Engineering, solve problems within technology, increase efficiency and productivity, and improve Systems engineering, s ...
and
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
.


Linear maps

If a
vector space In mathematics and physics, a vector space (also called a linear space) is a set (mathematics), set whose elements, often called vector (mathematics and physics), ''vectors'', can be added together and multiplied ("scaled") by numbers called sc ...
has a finite basis, its vectors are each uniquely represented by a finite
sequence In mathematics, a sequence is an enumerated collection of objects in which repetitions are allowed and order matters. Like a set, it contains members (also called ''elements'', or ''terms''). The number of elements (possibly infinite) is cal ...
of scalars, called a
coordinate vector In linear algebra, a coordinate vector is a representation of a vector as an ordered list of numbers (a tuple) that describes the vector in terms of a particular ordered basis. An easy example may be a position such as (5, 2, 1) in a 3-dimension ...
, whose elements are the
coordinates In geometry, a coordinate system is a system that uses one or more numbers, or coordinates, to uniquely determine and standardize the Position (geometry), position of the Point (geometry), points or other geometric elements on a manifold such as ...
of the vector on the basis. These coordinate vectors form another vector space, which is
isomorphic In mathematics, an isomorphism is a structure-preserving mapping or morphism between two structures of the same type that can be reversed by an inverse mapping. Two mathematical structures are isomorphic if an isomorphism exists between the ...
to the original vector space. A coordinate vector is commonly organized as a
column matrix A column or pillar in architecture and structural engineering is a structural element that transmits, through compression (physical), compression, the weight of the structure above to other structural elements below. In other words, a column i ...
(also called a ''column vector''), 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 In mathematics, and more specifically in linear algebra, a linear map (also called a linear mapping, linear transformation, vector space homomorphism, or in some contexts linear function) is a mapping V \to W between two vector spaces that p ...
from a vector space of dimension into a vector space of dimension maps a column vector :\mathbf x=\beginx_1 \\ x_2 \\ \vdots \\ x_n\end onto the column vector :\mathbf y= A(\mathbf x)= \begina_x_1+\cdots + a_x_n\\ a_x_1+\cdots + a_x_n \\ \vdots \\ a_x_1+\cdots + a_x_n\end. The linear map is thus defined by the matrix :\mathbf=\begin a_ & a_ & \cdots & a_ \\ a_ & a_ & \cdots & a_ \\ \vdots & \vdots & \ddots & \vdots \\ a_ & a_ & \cdots & a_ \\ \end, and maps the column vector \mathbf x to the matrix product :\mathbf y = \mathbf . If is another linear map from the preceding vector space of dimension , into a vector space of dimension , it is represented by a matrix \mathbf B. A straightforward computation shows that the matrix of the composite map is the matrix product \mathbf . The general formula ) that defines the function composition is instanced here as a specific case of associativity of matrix product (see below): :(\mathbf)\mathbf x = \mathbf(\mathbf ) = \mathbf.


Geometric rotations

Using a Cartesian coordinate system in a Euclidean plane, the
rotation Rotation or rotational/rotary motion is the circular movement of an object around a central line, known as an ''axis of rotation''. A plane figure can rotate in either a clockwise or counterclockwise sense around a perpendicular axis intersect ...
by an angle \alpha around the origin is a linear map. More precisely, \begin x' \\ y' \end = \begin \cos \alpha & - \sin \alpha \\ \sin \alpha & \cos \alpha \end \begin x \\ y \end, where the source point (x,y) and its image (x',y') are written as column vectors. The composition of the rotation by \alpha and that by \beta then corresponds to the matrix product \begin \cos \beta & - \sin \beta \\ \sin \beta & \cos \beta \end \begin \cos \alpha & - \sin \alpha \\ \sin \alpha & \cos \alpha \end = \begin \cos \beta \cos \alpha - \sin \beta \sin \alpha & - \cos \beta \sin \alpha - \sin \beta \cos \alpha \\ \sin \beta \cos \alpha + \cos \beta \sin \alpha & - \sin \beta \sin \alpha + \cos \beta \cos \alpha \end = \begin \cos (\alpha+\beta) & - \sin(\alpha+\beta) \\ \sin(\alpha+\beta) & \cos(\alpha+\beta) \end, where appropriate trigonometric identities are employed for the second equality. That is, the composition corresponds to the rotation by angle \alpha+\beta, as expected.


Resource allocation in economics

As an example, a fictitious factory uses 4 kinds of basic commodities, b_1, b_2, b_3, b_4 to produce 3 kinds of
intermediate good Intermediate goods, producer goods or semi-finished products are Good (economics), goods, such as partly finished goods, used as inputs in the production of other goods including final goods. A firm may make and then use intermediate goods, or mak ...
s, m_1, m_2, m_3, which in turn are used to produce 3 kinds of
final product In production, a final product or finished product is a product that is ready for sale,Wouters, Mark; Selto, Frank H.; Hilton, Ronald W.; Maher, Michael W. (2012): ''Cost Management: Strategies for Business Decisions'', International Edition, ...
s, f_1, f_2, f_3. The matrices :\mathbf = \begin 1 & 0 & 1 \\ 2 & 1 & 1 \\ 0 & 1 & 1 \\ 1 & 1 & 2 \\ \end   and   \mathbf = \begin 1 & 2 & 1 \\ 2 & 3 & 1 \\ 4 & 2 & 2 \\ \end provide 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 m_1, one unit of basic commodity b_1, two units of b_2, no units of b_3, and one unit of b_4 are needed, corresponding to the first column of \mathbf. Using matrix multiplication, compute :\mathbf = \begin 5 & 4 & 3 \\ 8 & 9 & 5 \\\ 6 & 5 & 3 \\ 11 & 9 & 6 \\ \end ; this matrix directly provides the amounts of basic commodities needed for given amounts of final goods. For example, the bottom left entry of \mathbf is computed as 1 \cdot 1 + 1 \cdot 2 + 2 \cdot 4 = 11, reflecting that 11 units of b_4 are needed to produce one unit of f_1. Indeed, one b_4 unit is needed for m_1, one for each of two m_2, and 2 for each of the four m_3 units that go into the f_1 unit, see picture. In order to produce e.g. 100 units of the final product f_1, 80 units of f_2, and 60 units of f_3, the necessary amounts of basic goods can be computed as :(\mathbf) \begin 100 \\ 80 \\ 60 \\ \end = \begin 1000 \\ 1820 \\ 1180 \\ 2180 \end , that is, 1000 units of b_1, 1820 units of b_2, 1180 units of b_3, 2180 units of b_4 are needed. Similarly, the product matrix \mathbf 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 In mathematics, a system of linear equations (or linear system) is a collection of two or more linear equations involving the same variable (math), variables. For example, : \begin 3x+2y-z=1\\ 2x-2y+4z=-2\\ -x+\fracy-z=0 \end is a system of th ...
is :\begina_x_1+\cdots + a_x_n=b_1, \\ a_x_1+\cdots + a_x_n =b_2, \\ \vdots \\ a_x_1+\cdots + a_x_n =b_m. \end Using same notation as above, such a system is equivalent with the single matrix
equation In mathematics, an equation is a mathematical formula that expresses the equality of two expressions, by connecting them with the equals sign . The word ''equation'' and its cognates in other languages may have subtly different meanings; for ...
:\mathbf=\mathbf b.


Dot product, bilinear form and sesquilinear form

The
dot product In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a Scalar (mathematics), scalar as a result". It is also used for other symmetric bilinear forms, for example in a pseudo-Euclidean space. N ...
of two column vectors is the unique entry of the matrix product :\mathbf x^\mathsf T \mathbf y, where \mathbf x^\mathsf T is the
row vector In linear algebra, a column vector with elements is an m \times 1 matrix consisting of a single column of entries, for example, \boldsymbol = \begin x_1 \\ x_2 \\ \vdots \\ x_m \end. Similarly, a row vector is a 1 \times n matrix for some , co ...
obtained by transposing \mathbf x. (As usual, a 1×1 matrix is identified with its unique entry.) More generally, any
bilinear form In mathematics, a bilinear form is a bilinear map on a vector space (the elements of which are called '' vectors'') over a field ''K'' (the elements of which are called '' scalars''). In other words, a bilinear form is a function that is linea ...
over a vector space of finite dimension may be expressed as a matrix product :\mathbf x^\mathsf T \mathbf , and any sesquilinear form may be expressed as :\mathbf x^\dagger \mathbf , where \mathbf x^\dagger denotes the
conjugate transpose In mathematics, the conjugate transpose, also known as the Hermitian transpose, of an m \times n complex matrix \mathbf is an n \times m matrix obtained by transposing \mathbf and applying complex conjugation to each entry (the complex conjugate ...
of \mathbf x (conjugate of the transpose, or equivalently transpose of the conjugate).


General properties

Matrix multiplication shares some properties with usual
multiplication Multiplication is one of the four elementary mathematical operations of arithmetic, with the other ones being addition, subtraction, and division (mathematics), division. The result of a multiplication operation is called a ''Product (mathem ...
. 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 In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Perhaps most familiar as a pr ...
if, given two elements and such that the product \mathbf\mathbf is defined, then \mathbf\mathbf is also defined, and \mathbf\mathbf=\mathbf\mathbf. If and are matrices of respective sizes and , then \mathbf\mathbf is defined if , and \mathbf\mathbf 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 :\mathbf\mathbf \neq \mathbf\mathbf. For example :\begin 0 & 1 \\ 0 & 0 \end\begin 0 & 0 \\ 1 & 0 \end=\begin 1 & 0 \\ 0 & 0 \end, but :\begin 0 & 0 \\ 1 & 0 \end\begin 0 & 1 \\ 0 & 0 \end = \begin 0 & 0 \\ 0 & 1 \end. This example may be expanded for showing that, if is a matrix with entries in a field , then \mathbf\mathbf = \mathbf\mathbf for every matrix with entries in ,
if and only if In logic and related fields such as mathematics and philosophy, "if and only if" (often shortened as "iff") is paraphrased by the biconditional, a logical connective between statements. The biconditional is true in two cases, where either bo ...
\mathbf=c\,\mathbf where , and is the
identity matrix In linear algebra, the identity matrix of size n is the n\times n square matrix with ones on the main diagonal and zeros elsewhere. It has unique properties, for example when the identity matrix represents a geometric transformation, the obje ...
. 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 (square) diagonal matrices (of the same size); 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 In mathematics, matrix addition is the operation of adding two matrices by adding the corresponding entries together. For a vector, \vec\!, adding two matrices would have the geometric effect of applying each matrix transformation separately ...
. That is, if are matrices of respective sizes , , , and , one has (left distributivity) :\mathbf(\mathbf + \mathbf) = \mathbf + \mathbf, and (right distributivity) :(\mathbf + \mathbf )\mathbf = \mathbf + \mathbf. This results from the distributivity for coefficients by :\sum_k a_(b_ + c_) = \sum_k a_b_ + \sum_k a_c_ :\sum_k (b_ + c_) d_ = \sum_k b_d_ + \sum_k c_d_.


Product with a scalar

If is a matrix and a scalar, then the matrices c\mathbf and \mathbfc are obtained by left or right multiplying all entries of by . If the scalars have the
commutative property In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Perhaps most familiar as a p ...
, then c\mathbf = \mathbfc. If the product \mathbf is defined (that is, the number of columns of equals the number of rows of ), then : c(\mathbf) = (c \mathbf)\mathbf and (\mathbf \mathbf)c=\mathbf(\mathbfc). 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: :c \left(\sum_k a_b_\right) = \sum_k (c a_ ) b_ :\left(\sum_k a_b_\right) c = \sum_k a_ ( b_c).


Transpose

If the scalars have the
commutative property In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Perhaps most familiar as a p ...
, the
transpose In linear algebra, the transpose of a Matrix (mathematics), matrix is an operator which flips a matrix over its diagonal; that is, it switches the row and column indices of the matrix by producing another matrix, often denoted by (among other ...
of a product of matrices is the product, in the reverse order, of the transposes of the factors. That is : (\mathbf)^\mathsf = \mathbf^\mathsf\mathbf^\mathsf where 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.


Complex conjugate

If and have
complex Complex commonly refers to: * Complexity, the behaviour of a system whose components interact in multiple ways so possible interactions are difficult to describe ** Complex system, a system composed of many components which may interact with each ...
entries, then : (\mathbf)^* = \mathbf^*\mathbf^* where denotes the entry-wise
complex conjugate In mathematics, the complex conjugate of a complex number is the number with an equal real part and an imaginary part equal in magnitude but opposite in sign. That is, if a and b are real numbers, then the complex conjugate of a + bi is a - ...
of a matrix. This results from applying to the definition of matrix product the fact that the conjugate of a sum is the sum of the conjugates of the summands and the conjugate of a product is the product of the conjugates of the factors. Transposition acts on the indices of the entries, while conjugation acts independently on the entries themselves. It results that, if and have complex entries, one has : (\mathbf)^\dagger = \mathbf^\dagger\mathbf^\dagger , where denotes the
conjugate transpose In mathematics, the conjugate transpose, also known as the Hermitian transpose, of an m \times n complex matrix \mathbf is an n \times m matrix obtained by transposing \mathbf and applying complex conjugation to each entry (the complex conjugate ...
(conjugate of the transpose, or equivalently transpose of the conjugate).


Associativity

Given three matrices and , the products and are defined if and only if the number of columns of equals the number of rows of , and the number of columns of equals the number of rows of (in particular, if one of the products is defined, then the other is also defined). In this case, one has the
associative property In mathematics, the associative property is a property of some binary operations that rearranging the parentheses in an expression will not change the result. In propositional logic, associativity is a Validity (logic), valid rule of replaceme ...
:(\mathbf)\mathbf=\mathbf(\mathbf). As for any associative operation, this allows omitting parentheses, and writing the above products as This extends naturally to the product of any number of matrices provided that the dimensions match. That is, if are matrices such that the number of columns of equals the number of rows of for , then the product : \prod_^n \mathbf_i = \mathbf_1\mathbf_2\cdots\mathbf_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 In mathematics, summation is the addition of a sequence of numbers, called ''addends'' or ''summands''; the result is their ''sum'' or ''total''. Beside numbers, other types of values can be summed as well: functions, vectors, matrices, pol ...
manipulations. This result also follows from the fact that matrices represent
linear map In mathematics, and more specifically in linear algebra, a linear map (also called a linear mapping, linear transformation, vector space homomorphism, or in some contexts linear function) is a mapping V \to W between two vector spaces that p ...
s. Therefore, the associative property of matrices is simply a specific case of the associative property of
function composition In mathematics, the composition operator \circ takes two function (mathematics), functions, f and g, and returns a new function h(x) := (g \circ f) (x) = g(f(x)). Thus, the function is function application, applied after applying to . (g \c ...
.


Computational complexity depends on parenthesization

Although the result of a sequence of matrix products does not depend on the order of operation (provided that the order of the matrices is not changed), the
computational complexity In computer science, the computational complexity or simply complexity of an algorithm is the amount of resources required to run it. Particular focus is given to computation time (generally measured by the number of needed elementary operations ...
may depend dramatically on this order. For example, if and are matrices of respective sizes , computing needs multiplications, while computing needs multiplications. Algorithms have been designed for choosing the best order of products; see Matrix chain multiplication. When the number of matrices increases, it has been shown that the choice of the best order has a complexity of O(n \log n).


Application to similarity

Any
invertible matrix In linear algebra, an invertible matrix (''non-singular'', ''non-degenarate'' or ''regular'') is a square matrix that has an inverse. In other words, if some other matrix is multiplied by the invertible matrix, the result can be multiplied by a ...
\mathbf defines a similarity transformation (on square matrices of the same size as \mathbf) :S_\mathbf(\mathbf) = \mathbf^ \mathbf \mathbf. Similarity transformations map product to products, that is :S_\mathbf(\mathbf) = S_\mathbf(\mathbf)S_\mathbf(\mathbf). In fact, one has :\mathbf^ (\mathbf) \mathbf = \mathbf^ \mathbf(\mathbf\mathbf^)\mathbf \mathbf =(\mathbf^ \mathbf\mathbf)(\mathbf^\mathbf \mathbf).


Square matrices

Let us denote \mathcal M_n(R) the set of square matrices with entries in a ring , which, in practice, is often a field. In \mathcal M_n(R), the product is defined for every pair of matrices. This makes \mathcal M_n(R) a ring, which has the
identity matrix In linear algebra, the identity matrix of size n is the n\times n square matrix with ones on the main diagonal and zeros elsewhere. It has unique properties, for example when the identity matrix represents a geometric transformation, the obje ...
as
identity element In mathematics, an identity element or neutral element of a binary operation is an element that leaves unchanged every element when the operation is applied. For example, 0 is an identity element of the addition of real numbers. This concept is use ...
(the matrix whose diagonal entries are equal to 1 and all other entries are 0). This ring is also an associative -algebra. If , many matrices do not have a
multiplicative inverse In mathematics, a multiplicative inverse or reciprocal for a number ''x'', denoted by 1/''x'' or ''x''−1, is a number which when Multiplication, multiplied by ''x'' yields the multiplicative identity, 1. The multiplicative inverse of a ra ...
. For example, a matrix such that all entries of a row (or a column) are 0 does not have an inverse. If it exists, the inverse of a matrix is denoted , and, thus verifies : \mathbf\mathbf^ = \mathbf^\mathbf = \mathbf. A matrix that has an inverse is an
invertible matrix In linear algebra, an invertible matrix (''non-singular'', ''non-degenarate'' or ''regular'') is a square matrix that has an inverse. In other words, if some other matrix is multiplied by the invertible matrix, the result can be multiplied by a ...
. Otherwise, it is a singular matrix. A product of matrices is invertible if and only if each factor is invertible. In this case, one has :(\mathbf\mathbf)^ = \mathbf^\mathbf^. When is
commutative In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Perhaps most familiar as a pr ...
, and, in particular, when it is a field, the
determinant In mathematics, the determinant is a Scalar (mathematics), scalar-valued function (mathematics), function of the entries of a square matrix. The determinant of a matrix is commonly denoted , , or . Its value characterizes some properties of the ...
of a product is the product of the determinants. As determinants are scalars, and scalars commute, one has thus : \det(\mathbf) = \det(\mathbf) =\det(\mathbf)\det(\mathbf). The other matrix invariants do not behave as well with products. Nevertheless, if is commutative, and have the same trace, the same
characteristic polynomial In linear algebra, the characteristic polynomial of a square matrix is a polynomial which is invariant under matrix similarity and has the eigenvalues as roots. It has the determinant and the trace of the matrix among its coefficients. The ...
, and the same
eigenvalues In linear algebra, an eigenvector ( ) or characteristic vector is a vector that has its direction unchanged (or reversed) by a given linear transformation. More precisely, an eigenvector \mathbf v of a linear transformation T is scaled by a ...
with the same multiplicities. However, the
eigenvector In linear algebra, an eigenvector ( ) or characteristic vector is a vector that has its direction unchanged (or reversed) by a given linear transformation. More precisely, an eigenvector \mathbf v of a linear transformation T is scaled by ...
s are generally different if .


Powers of a matrix

One may raise a square matrix to any nonnegative integer power multiplying it by itself repeatedly in the same way as for ordinary numbers. That is, :\mathbf^0 = \mathbf, :\mathbf^1 = \mathbf, :\mathbf^k = \underbrace_. Computing the th power of a matrix needs times the time of a single matrix multiplication, if it is done with the trivial algorithm (repeated multiplication). As this may be very time consuming, one generally prefers using exponentiation by squaring, which requires less than matrix multiplications, and is therefore much more efficient. An easy case for exponentiation is that of a
diagonal matrix In linear algebra, a diagonal matrix is a matrix in which the entries outside the main diagonal are all zero; the term usually refers to square matrices. Elements of the main diagonal can either be zero or nonzero. An example of a 2×2 diagon ...
. Since the product of diagonal matrices amounts to simply multiplying corresponding diagonal elements together, the th power of a diagonal matrix is obtained by raising the entries to the power : : \begin a_ & 0 & \cdots & 0 \\ 0 & a_ & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & a_ \end^k = \begin a_^k & 0 & \cdots & 0 \\ 0 & a_^k & \cdots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \cdots & a_^k \end.


Abstract algebra

The definition of matrix product requires that the entries belong to a semiring, and does not require multiplication of elements of the semiring to be
commutative In mathematics, a binary operation is commutative if changing the order of the operands does not change the result. It is a fundamental property of many binary operations, and many mathematical proofs depend on it. Perhaps most familiar as a pr ...
. In many applications, the matrix elements belong to a field, although the
tropical semiring In idempotent analysis, the tropical semiring is a semiring of extended real numbers with the operations of minimum (or maximum) and addition replacing the usual ("classical") operations of addition and multiplication, respectively. The tropical s ...
is also a common choice for graph shortest path problems. Even in the case of matrices over fields, the product is not commutative in general, although it is
associative In mathematics, the associative property is a property of some binary operations that rearranging the parentheses in an expression will not change the result. In propositional logic, associativity is a valid rule of replacement for express ...
and is distributive over
matrix addition In mathematics, matrix addition is the operation of adding two matrices by adding the corresponding entries together. For a vector, \vec\!, adding two matrices would have the geometric effect of applying each matrix transformation separately ...
. The identity matrices (which are the square matrices whose entries are zero outside of the main diagonal and 1 on the main diagonal) are
identity element In mathematics, an identity element or neutral element of a binary operation is an element that leaves unchanged every element when the operation is applied. For example, 0 is an identity element of the addition of real numbers. This concept is use ...
s of the matrix product. It follows that the matrices over a ring form a ring, which is noncommutative except if and the ground ring is commutative. A square matrix may have a
multiplicative inverse In mathematics, a multiplicative inverse or reciprocal for a number ''x'', denoted by 1/''x'' or ''x''−1, is a number which when Multiplication, multiplied by ''x'' yields the multiplicative identity, 1. The multiplicative inverse of a ra ...
, called an inverse matrix. In the common case where the entries belong to a
commutative ring In mathematics, a commutative ring is a Ring (mathematics), ring in which the multiplication operation is commutative. The study of commutative rings is called commutative algebra. Complementarily, noncommutative algebra is the study of ring prope ...
, a matrix has an inverse if and only if its
determinant In mathematics, the determinant is a Scalar (mathematics), scalar-valued function (mathematics), function of the entries of a square matrix. The determinant of a matrix is commonly denoted , , or . Its value characterizes some properties of the ...
has a multiplicative inverse in . The determinant of a product of square matrices is the product of the determinants of the factors. The matrices that have an inverse form a group under matrix multiplication, the
subgroup In group theory, a branch of mathematics, a subset of a group G is a subgroup of G if the members of that subset form a group with respect to the group operation in G. Formally, given a group (mathematics), group under a binary operation  ...
s of which are called matrix groups. Many classical groups (including all
finite group In abstract algebra, a finite group is a group whose underlying set is finite. Finite groups often arise when considering symmetry of mathematical or physical objects, when those objects admit just a finite number of structure-preserving tra ...
s) are
isomorphic In mathematics, an isomorphism is a structure-preserving mapping or morphism between two structures of the same type that can be reversed by an inverse mapping. Two mathematical structures are isomorphic if an isomorphism exists between the ...
to matrix groups; this is the starting point of the theory of
group representation In the mathematical field of representation theory, group representations describe abstract groups in terms of bijective linear transformations of a vector space to itself (i.e. vector space automorphisms); in particular, they can be used ...
s. Matrices are the
morphisms In mathematics, a morphism is a concept of category theory that generalizes structure-preserving maps such as homomorphism between algebraic structures, functions from a set to another set, and continuous functions between topological spaces. Al ...
of a
category Category, plural categories, may refer to: General uses *Classification, the general act of allocating things to classes/categories Philosophy * Category of being * ''Categories'' (Aristotle) * Category (Kant) * Categories (Peirce) * Category ( ...
, the
category of matrices In mathematics, the category of matrices, often denoted \mathbf, is the category (category theory), category whose object (category theory), objects are natural numbers and whose morphisms are matrix (mathematics), matrices, with composition give ...
. The objects are the
natural number In mathematics, the natural numbers are the numbers 0, 1, 2, 3, and so on, possibly excluding 0. Some start counting with 0, defining the natural numbers as the non-negative integers , while others start with 1, defining them as the positive in ...
s that measure the size of matrices, and the composition of morphisms is matrix multiplication. The source of a morphism is the number of columns of the corresponding matrix, and the target is the number of rows.


Computational complexity

The matrix multiplication
algorithm In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
that results from the definition requires, in the
worst case In computer science, best, worst, and average cases of a given algorithm express what the resource usage is ''at least'', ''at most'' and ''on average'', respectively. Usually the resource being considered is running time, i.e. time complexity, b ...
, multiplications and additions of scalars to compute the product of two square matrices. Its
computational complexity In computer science, the computational complexity or simply complexity of an algorithm is the amount of resources required to run it. Particular focus is given to computation time (generally measured by the number of needed elementary operations ...
is therefore , in a
model of computation In computer science, and more specifically in computability theory and computational complexity theory, a model of computation is a model which describes how an output of a mathematical function is computed given an input. A model describes how ...
for which the scalar operations take constant time. Rather surprisingly, this complexity is not optimal, as shown in 1969 by Volker Strassen, who provided an algorithm, now called Strassen's algorithm, with a complexity of O( n^) \approx O(n^). Strassen's algorithm can be parallelized to further improve the performance. , the best peer-reviewed matrix multiplication algorithm is by Virginia Vassilevska Williams, Yinzhan Xu, Zixuan Xu, and Renfei Zhou and has complexity . It is not known whether matrix multiplication can be performed in time.that is, in time , for some function with as This would be optimal, since one must read the elements of a matrix in order to multiply it with another matrix. Since matrix multiplication forms the basis for many algorithms, and many operations on matrices even have the same complexity as matrix multiplication (up to a multiplicative constant), the computational complexity of matrix multiplication appears throughout numerical linear algebra and
theoretical computer science Theoretical computer science is a subfield of computer science and mathematics that focuses on the Abstraction, abstract and mathematical foundations of computation. It is difficult to circumscribe the theoretical areas precisely. The Associati ...
.


Generalizations

Other types of products of matrices include: * Block matrix operations * Cracovian product, defined as * Frobenius inner product, the
dot product In mathematics, the dot product or scalar productThe term ''scalar product'' means literally "product with a Scalar (mathematics), scalar as a result". It is also used for other symmetric bilinear forms, for example in a pseudo-Euclidean space. N ...
of matrices considered as vectors, or, equivalently the sum of the entries of the Hadamard product * Hadamard product of two matrices of the same size, resulting in a matrix of the same size, which is the product entry-by-entry *
Kronecker product In mathematics, the Kronecker product, sometimes denoted by ⊗, is an operation on two matrices of arbitrary size resulting in a block matrix. It is a specialization of the tensor product (which is denoted by the same symbol) from vector ...
or
tensor product In mathematics, the tensor product V \otimes W of two vector spaces V and W (over the same field) is a vector space to which is associated a bilinear map V\times W \rightarrow V\otimes W that maps a pair (v,w),\ v\in V, w\in W to an element of ...
, the generalization to any size of the preceding * Khatri–Rao product and face-splitting product *
Outer product In linear algebra, the outer product of two coordinate vectors is the matrix whose entries are all products of an element in the first vector with an element in the second vector. If the two coordinate vectors have dimensions ''n'' and ''m'', the ...
, also called dyadic product or
tensor product In mathematics, the tensor product V \otimes W of two vector spaces V and W (over the same field) is a vector space to which is associated a bilinear map V\times W \rightarrow V\otimes W that maps a pair (v,w),\ v\in V, w\in W to an element of ...
of two column matrices, which is \mathbf\mathbf^\mathsf *
Scalar multiplication In mathematics, scalar multiplication is one of the basic operations defining a vector space in linear algebra (or more generally, a module in abstract algebra). In common geometrical contexts, scalar multiplication of a real Euclidean vector ...


See also

*
Matrix calculus In mathematics, matrix calculus is a specialized notation for doing multivariable calculus, especially over spaces of matrix (mathematics), matrices. It collects the various partial derivatives of a single Function (mathematics), function with ...
, for the interaction of matrix multiplication with operations from calculus


Notes


References

* Henry Cohn, Robert Kleinberg, Balázs Szegedy, and Chris Umans. Group-theoretic Algorithms for Matrix Multiplication. . ''Proceedings of the 46th Annual Symposium on Foundations of Computer Science'', 23–25 October 2005, Pittsburgh, PA, IEEE Computer Society, pp. 379–388. * Henry Cohn, Chris Umans. A Group-theoretic Approach to Fast Matrix Multiplication. . ''Proceedings of the 44th Annual IEEE Symposium on Foundations of Computer Science'', 11–14 October 2003, Cambridge, MA, IEEE Computer Society, pp. 438–449. * * * Knuth, D.E., '' The Art of Computer Programming Volume 2: Seminumerical Algorithms''. Addison-Wesley Professional; 3 edition (November 14, 1997). . pp. 501. * . *
Ran Raz Ran Raz () is a computer scientist who works in the area of computational complexity theory. He was a professor in the Faculty of Mathematics and Computer Science at the Weizmann Institute before becoming a professor of computer science at Prince ...
. On the complexity of matrix product. In Proceedings of the thirty-fourth annual ACM symposium on Theory of computing. ACM Press, 2002. . * Robinson, Sara, ''Toward an Optimal Algorithm for Matrix Multiplication,'' SIAM News 38(9), November 2005
PDF
* Strassen, Volker, ''Gaussian Elimination is not Optimal'', Numer. Math. 13, p. 354–356, 1969. * * {{Linear algebra Matrix theory Bilinear maps Multiplication Numerical linear algebra