This article gives an overview of the various ways to multiply matrices.
By far the most important way to multiply matrices is the usual matrix multiplication. It is defined between two matrices only if the number of columns of the first matrix is the same as the number of rows of the second matrix. If A is an m-by-n matrix and B is an n-by-p matrix, then their product is an m-by-p matrix denoted by AB (or sometimes A · B). The product is given by
for each pair i and j with 1 ≤ i ≤ m and 1 ≤ j ≤ p. The algebraic system of "matrix units" summarises the abstract properties of this kind of multiplication.
The picture to the left shows how to calculate the (1,2) element and the (3,3) element of AB if A is a 4×2 matrix, and B is a 2×3 matrix. Elements from each matrix are paired off in the direction of the arrows; each pair is multiplied and the products are added. The location of the resulting number in AB corresponds to the row and column that were considered.
This matrix multiplication can also be considered from a slightly different viewpoint: it adds vectors together after being multiplied by different coefficients. If A and B are matricies given by:
\begin{bmatrix} a_{1,1} & a_{1,2} & \dots \\ a_{2,1} & a_{2,2} & \dots \\ \vdots & \vdots & \ddots \end{bmatrix}
and
\begin{bmatrix} b_{1,1} & b_{1,2} & \dots \\ b_{2,1} & b_{2,2} & \dots \\ \vdots & \vdots & \ddots \end{bmatrix}
then
For example:
= \begin{bmatrix} 5 & 1 \\ 4 & 2 \end{bmatrix}
The rows in the matrix on the left is the list of coefficients. The matrix on the right is the list of vectors. In the example, the first row is *, and thus we take 1 times the first vector, 0 times the second vector, and 2 times the third vector.
The ordinary matrix product can be thought of as a dot product of a column-list of vectors and a row-list of vectors. If A and B are matricies given by:
\begin{bmatrix} a_{1,1} & a_{1,2} & a_{1,3} & \dots \\ a_{2,1} & a_{2,2} & a_{2,3} & \dots \\ a_{3,1} & a_{3,2} & a_{3,3} & \dots \\ \vdots & \vdots & \vdots & \ddots \end{bmatrix} = \begin{bmatrix} A_1 \\ A_2 \\ A_3 \\ \vdots \end{bmatrix}
and
\begin{bmatrix} b_{1,1} & b_{1,2} & b_{1,3} & \dots \\ b_{2,1} & b_{2,2} & b_{2,3} & \dots \\ b_{3,1} & b_{3,2} & b_{3,3} & \dots \\ \vdots & \vdots & \vdots & \ddots \end{bmatrix} = \begin{bmatrix} B_1 & B_2 & B_3 & \dots \end{bmatrix}
where
then
\begin{bmatrix} A_1 \\ A_2 \\ A_3 \\ \vdots \end{bmatrix}
\end{bmatrix}
Although matrix multiplication is not commutative, the determinants of AB and BA are always equal (if A and B are square matrices of the same size). See the article on determinants for an explanation.
This notion of multiplication is important because if A and B are interpreted as linear transformations (which is almost universally done), then the matrix product AB corresponds to the composition of the two linear transformations, with B being applied first.
The complexity of matrix multiplication, if carried out naively, is O(n3), but more efficient algorithms do exist. Strassen's algorithm, devised by Volker Strassen in 1969 and often referred to as "fast matrix multiplication", is based on a clever way of multiplying two 2 × 2 matrices which requires only 7 multiplications (instead of the usual 8). Applying this trick recursively gives an algorithm with a cost of O(nlog2(7)) = O(n2.807...). In practice, though, it is rarely used since it is awkward to implement and it lacks numerical stability. The constant factor involved is about 4.695 asymptotically; Winograd's method improves on this slightly by reducing it to an asymptotic 4.537.
The best algorithm currently known, which was presented by Don Coppersmith and S. Winograd in 1990, has an asymptotic complexity of O(n2.376). It is similar to Strassen's algorithm: a clever way is devised for multiplying two k × k matrices with less than k3 multiplications, and this technique is applied recursively. However, the constant implied in the O(n2.376) result is so large that the Coppersmith–Winograd algorithm is only worthwhile for matrices that are too big to handle on present-day computers.
Since any algorithm for multiplying two n × n matrices has to process all n2 entries, it cannot run faster than O(n2). Most researchers believe that an optimal algorithm will run in essentially O(n2) time (Robinson, 2005).
The scalar multiplication of a matrix A = (aij) and a scalar r gives a product rA of the same size as A. The entries of rA are given by
If we are concerned with matrices over a ring, then the above multiplication is sometimes called the left multiplication while the right multiplication is defined to be
When the underlying ring is commutative, for example, the real or complex number field, the two multiplications are the same. However, if the ring is not commutative, such as the quaternions, they may be different. For example
For two matrices of the same dimensions, we have the Hadamard product or entrywise product. The Hadamard product of two m-by-n matrices A and B, denoted by A • B, is an m-by-n matrix given by (A•B)ij = aijbij. For instance
Note that the Hadamard product is a submatrix of the Kronecker product (see below). The Hadamard product is studied by matrix theorists, but it is virtually untouched by linear algebraists. It is discussed in (Horn & Johnson, 1994, Ch. 5).
For any two arbitrary matrices A and B, we have the direct product or Kronecker product A B defined as
Note that if A is m-by-n and B is p-by-r then A B is an mp-by-nr matrix. Again this multiplication is not commutative.
For example
= \begin{bmatrix} 0 & 3 & 0 & 6 \\ 2 & 1 & 4 & 2 \\ 0 & 9 & 0 & 3 \\ 6 & 3 & 2 & 1 \end{bmatrix} .
If A and B represent linear transformations V1 → W1 and V2 → W2, respectively, then A B represents the tensor product of the two maps, V1 V2 → W1 W2.
All three notions of matrix multiplication are associative:
Matrix theory | Binary operations
Násobení matic | Producto de matrices | Produit matriciel | Moltiplicazione di matrici | כפל מטריצות | Matrixvermenigvuldiging | Mnożenie macierzy
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Matrix multiplication".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world