Added to Favorites

Related Searches

Definitions

Nearby Words

In mathematics, matrix multiplication is the operation of multiplying a matrix with either a scalar or another matrix. This article gives an overview of the various ways to perform matrix multiplication.
## Ordinary matrix product

### Calculating directly from the definition

### The coefficients-vectors method

### Vector-lists method

### Properties

### Algorithms

### Relationship to linear transformations

Matrices offer a concise way of representing linear transformations between vector spaces, and (ordinary) matrix multiplication corresponds to the composition of linear transformations. This will be illustrated here by means of an example using three vector spaces of specific dimensions, but the correspondence applies equally to any other choice of dimensions._{i} can be expressed in terms of the z_{k}:
## Scalar multiplication

## Hadamard product

## Kronecker product

Main article: Kronecker product.## Common properties

## Frobenius inner product

The Frobenius inner product, sometimes denoted A:B is the component-wise inner product of two matrices as though they are vectors. In other words, it is the sum of the entries of the Hadamard product, that is,
## See also

## References

## External links

This is the most often used and most important way to multiply matrices. 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.

Formally, for

- $A\; in\; \{mathbb\; R\}^\{m\; times\; n\}$, $B\; in\; \{mathbb\; R\}^\{n\; times\; p\}$

- $(AB)\; in\; \{mathbb\; R\}^\{m\; times\; p\}$

- $(AB)\_\{i,j\}\; =\; sum\_\{r=1\}^n\; A\_\{i,r\}B\_\{r,j\}$

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.

- $(mathbf\{AB\})\_\{1,2\}\; =\; sum\_\{r=1\}^2\; a\_\{1,r\}b\_\{r,2\}\; =\; a\_\{1,1\}b\_\{1,2\}+a\_\{1,2\}b\_\{2,2\}$

- $(mathbf\{AB\})\_\{3,3\}\; =\; sum\_\{r=1\}^2\; a\_\{3,r\}b\_\{r,3\}\; =\; a\_\{3,1\}b\_\{1,3\}+a\_\{3,2\}b\_\{2,3\}$

For example:

- $$

1 & 0 & 2

-1 & 3 & 1end{bmatrix} cdot begin{bmatrix}

3 & 1

2 & 1

1 & 0end{bmatrix} = begin{bmatrix}

1 times 3 + 0 times 2 + 2 times 1 & 1 times 1 + 0 times 1 + 2 times 0

-1 times 3 + 3 times 2 + 1 times 1 & -1 times 1 + 3 times 1 + 1 times 0end{bmatrix} = begin{bmatrix}

5 & 1

4 & 2end{bmatrix}

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 matrices given by:

- $mathbf\{A\}\; =$

begin{bmatrix} a_{1,1} & a_{1,2} & dots a_{2,1} & a_{2,2} & dots

vdots & vdots & ddotsend{bmatrix}

and $mathbf\{B\}\; =$

begin{bmatrix} b_{1,1} & b_{1,2} & dots b_{2,1} & b_{2,2} & dots

vdots & vdots & ddotsend{bmatrix} = begin{bmatrix}

B_1

B_2

vdotsend{bmatrix}

then

- $$

vdotsend{bmatrix}

The example revisited:

- $$

1 & 0 & 2

-1 & 3 & 1end{bmatrix} cdot begin{bmatrix}

3 & 1

2 & 1

1 & 0end{bmatrix} = begin{bmatrix} 1 begin{bmatrix} 3 & 1 end{bmatrix} + 0 begin{bmatrix} 2 & 1 end{bmatrix} + 2 begin{bmatrix} 1 & 0 end{bmatrix} -1 begin{bmatrix} 3 & 1 end{bmatrix} + 3 begin{bmatrix} 2 & 1 end{bmatrix} + 1 begin{bmatrix} 1 & 0 end{bmatrix} end{bmatrix} = begin{bmatrix} begin{bmatrix} 3 & 1 end{bmatrix} + begin{bmatrix} 0 & 0 end{bmatrix} + begin{bmatrix} 2 & 0 end{bmatrix} begin{bmatrix} -3 & -1 end{bmatrix} + begin{bmatrix} 6 & 3 end{bmatrix} + begin{bmatrix} 1 & 0 end{bmatrix} end{bmatrix}

- $$

= begin{bmatrix}

5 & 1

4 & 2end{bmatrix}

The rows in the matrix on the left can be thought of as the list of coefficients and the matrix on the right as the list of vectors. In the example, the first row is [1 0 2], and thus we take 1 times the first vector, 0 times the second vector, and 2 times the third vector.

The equation can be simplified further by using outer products:

- $mathbf\{A\}\; =$

A_1 & A_2 & dotsend{bmatrix} implies mathbf{AB} = sum_i A_iB_i

The terms of this sum are matrices of the same shape, each describing the effect of one column of A and one row of B on the result. The columns of A can be seen as a coordinate system of the transform, i.e. given a vector x we have $mathbf\{A\}x=A\_1x\_1+A\_2x\_2+cdots$ where $x\_i$ are coordinates along the $A\_i$ "axes". The terms $A\_iB\_i$ are like $A\_ix\_i$, except that $B\_i$ contains the ith coordinate for each column vector of B, each of which is transformed independently in parallel.

The example revisited:

- $$

1 & 0 & 2

-1 & 3 & 1end{bmatrix} cdot begin{bmatrix}

3 & 1

2 & 1

1 & 0end{bmatrix} = begin{bmatrix}1 -1end{bmatrix}begin{bmatrix}3 & 1end{bmatrix}+ begin{bmatrix}0 3end{bmatrix}begin{bmatrix}2 & 1end{bmatrix}+ begin{bmatrix}2 1end{bmatrix}begin{bmatrix}1 & 0end{bmatrix}

- $$

The vectors $begin\{bmatrix\}3\; \&\; 2\; \&\; 1end\{bmatrix\}^top$ and $begin\{bmatrix\}1\; \&\; 1\; \&\; 0end\{bmatrix\}^top$ have been transformed to $begin\{bmatrix\}5\; \&\; 4end\{bmatrix\}^top$ and $begin\{bmatrix\}1\; \&\; 2end\{bmatrix\}^top$ in parallel. One could also transform them one by one with the same steps:

- $$

1 & 0 & 2

-1 & 3 & 1end{bmatrix} cdot begin{bmatrix}

3

2

1end{bmatrix} = begin{bmatrix}1 -1end{bmatrix}3+ begin{bmatrix}0 3end{bmatrix}2+ begin{bmatrix}2 1end{bmatrix}1 = begin{bmatrix} 1cdot 3 -1cdot 3end{bmatrix}+ begin{bmatrix} 0cdot 2 3cdot 2end{bmatrix}+ begin{bmatrix} 2cdot 1 1cdot 1end{bmatrix} = begin{bmatrix} 5 4 end{bmatrix}

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 matrices given by:

- $mathbf\{A\}\; =$

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 & ddotsend{bmatrix} = begin{bmatrix}

A_1

A_2

A_3

vdotsend{bmatrix}

and $mathbf\{B\}\; =$

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 & ddotsend{bmatrix} = begin{bmatrix} B_1 & B_2 & B_3 & dots end{bmatrix}

where

- A
_{1}is the row vector of all elements of the form a_{1,x}A_{2}is the row vector of all elements of the form a_{2,x}etc,

- and B
_{1}is the column vector of all elements of the form b_{x,1}B_{2}is the column vector of all elements of the form b_{x,2}etc,

then

- $$

begin{bmatrix}

A_1

A_2

A_3

vdotsend{bmatrix} * begin{bmatrix} B_1 & B_2 & B_3 & dots end{bmatrix} = begin{bmatrix} (A_1 cdot B_1) & (A_1 cdot B_2) & (A_1 cdot B_3) & dots (A_2 cdot B_1) & (A_2 cdot B_2) & (A_2 cdot B_3) & dots (A_3 cdot B_1) & (A_3 cdot B_2) & (A_3 cdot B_3) & dots vdots & vdots & vdots & ddots

end{bmatrix}.

- Matrix multiplication is not guaranteed to be commutative (though it sometimes can be by coincidence)

- $AB\; ne\; BA$

- If A and B are square matrices of equal dimension, then the determinants of their product is equal, regardless of order.

- $det(AB)\; =\; det(BA)$

- If both matrices are diagonal square matrices of the same dimension, their product is commutative.
- If A is a matrix representative of a linear transformation L and B is a matrix representative of a linear transformation P then AB is a matrix representative of a linear transform P followed by the linear transformation L. Note that although it appears the transformations are done in reverse order, this is actually the "correct" order because the right-most function is always performed first in function composition. Thus the linear transformation corresponding to B should be done first.
- Matrix multiplication is associative:

- $mathbf\{A\}\; (mathbf\{B\; C\}\; )\; =\; (mathbf\{A\; B\}\; )\; mathbf\{C\}$

- Matrix multiplication is distributive:

- $mathbf\{A\}\; (mathbf\{B\}\; +\; mathbf\{C\}\; )\; =\; mathbf\{A\; B\}\; +\; mathbf\{AC\}$

- $(mathbf\{A\}\; +\; mathbf\{B\}\; )\; mathbf\{C\}\; =\; mathbf\{A\; C\}\; +\; mathbf\{B\; C\}$.

- If the matrix is defined over a field (for example, over the Real or Complex fields), then it is compatible with scalar multiplication

- $c\; (mathbf\{A\; B\}\; )\; =\; (c\; mathbf\{A\}\; )\; mathbf\{B\}$

- $(mathbf\{A\}\; c\; )\; mathbf\{B\}\; =\; mathbf\{A\}\; (c\; mathbf\{B\}\; )$

- $(mathbf\{A\; B\}\; )\; c\; =\; mathbf\{A\}\; (mathbf\{B\}\; c\; )$

- where c is a scalar.

The complexity of matrix multiplication, if carried out naively, is $O(n^3\; )$, 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), at the expense of several additional addition and subtraction operations. Applying this trick recursively gives an algorithm with a multiplicative cost of $O(n^\{log\_\{2\}7\})\; approx\; O(n^\{2.807\})$. Strassen's algorithm is awkward to implement, compared to the naive algorithm, and it lacks numerical stability. Nevertheless, it is beginning to appear in libraries such as BLAS, where it is computationally interesting for matricies with dimensions n > 100 (Press 2007, p. 108).

The algorithm with the lowest known exponent, which was presented by Don Coppersmith and Shmuel Winograd in 1990, has an asymptotic complexity of O(n^{2.376}). It is similar to Strassen's algorithm: a clever way is devised for multiplying two k × k matrices with fewer than k³ multiplications, and this technique is applied recursively. It improves on the constant factor in Strassen's algorithm, reducing it to 4.537. However, the constant term implied in the O(n^{2.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 (Knuth, 1998).

Since any algorithm for multiplying two n × n matrices has to process all 2 × n² entries, there is an asymptotic lower bound of $omega\; (n^2)$ operations. Raz (2002) proves a lower bound of $Omega(m^2\; log\; m)$ for bounded coefficient arithmetic circuits over the real or complex numbers.

Cohn et al. (2003, 2005) put methods such as the Strassen and Coppersmith–Winograd algorithms in an entirely different, group-theoretic context. They show that if families of wreath products of Abelian with symmetric groups satisfying certain conditions exists, matrix multiplication algorithms with essential quadratic complexity exist. Most researchers believe that this is indeed the case (Robinson, 2005).

Because of the nature of Matrix operations and the layout of Matrices in memory, it is typically possible to gain substantial performance gains through use of parallelisation and vectorisation. It should therefore be noted that some lower time-complexity algorithms on paper may have indirect time complexity costs on real machines.

Let X, Y, and Z be three vector spaces, with dimensions 4, 2, and 3, respectively, all over the same field, for example the real numbers. The coordinates of a point in X will be denoted as x_{i}, for i = 1 to 4, and analogously for the other two spaces.

Two linear transformations are given: one from Y to X, which can be expressed by the system of linear equations

- $begin\{align\}$

- $begin\{align\}$

- $begin\{align\}$

- $$

x_1

x_2

x_3

x_4end{bmatrix} = begin{bmatrix} a_{1,1} & a_{1,2} a_{2,1} & a_{2,2} a_{3,1} & a_{3,2} a_{4,1} & a_{4,2} end{bmatrix} cdot begin{bmatrix}

y_1

y_2end{bmatrix}

- $$

y_1

y_2end{bmatrix} = begin{bmatrix} b_{1,1} & b_{1,2} & b_{1,3} b_{2,1} & b_{2,2} & b_{2,3} end{bmatrix} cdot begin{bmatrix}

z_1

z_2

z_3end{bmatrix}

- $$

x_1

x_2

x_3

x_4end{bmatrix} = begin{bmatrix} a_{1,1} b_{1,1}{+}a_{1,2} b_{2,1} & a_{1,1} b_{1,2}{+}a_{1,2} b_{2,2} & a_{1,1} b_{1,3}{+}a_{1,2} b_{2,3} a_{2,1} b_{1,1}{+}a_{2,2} b_{2,1} & a_{2,1} b_{1,2}{+}a_{2,2} b_{2,2} & a_{2,1} b_{1,3}{+}a_{2,2} b_{2,3} a_{3,1} b_{1,1}{+}a_{3,2} b_{2,1} & a_{3,1} b_{1,2}{+}a_{3,2} b_{2,2} & a_{3,1} b_{1,3}{+}a_{3,2} b_{2,3} a_{4,1} b_{1,1}{+}a_{4,2} b_{2,1} & a_{4,1} b_{1,2}{+}a_{4,2} b_{2,2} & a_{4,1} b_{1,3}{+}a_{4,2} b_{2,3} end{bmatrix} cdot begin{bmatrix}

z_1

z_2

z_3end{bmatrix} Representing these three equations symbolically and more concisely as

- $$

This can be used to formulate a more abstract definition of matrix multiplication, given the special case of matrix–vector multiplication: the product AB of matrices A and B is the matrix C such that for all vectors z of the appropriate shape .

The scalar multiplication of a matrix A = (a_{ij}) and a scalar r gives a product r A of the same size as A. The entries of r A are given by

- $(rmathbf\{A\})\_\{ij\}\; =\; r\; cdot\; a\_\{ij\}.\; ,$

- $mathbf\{A\}=begin\{bmatrix\}\; 1\; \&\; 2\; 3\; \&\; 4\; end\{bmatrix\}$

- $7\; mathbf\{A\}=begin\{bmatrix\}\; 7\; cdot\; 1\; \&\; 7\; cdot\; 2\; 7\; cdot\; 3\; \&\; 7\; cdot\; 4\; end\{bmatrix\}\; =\; begin\{bmatrix\}\; 7\; \&\; 14\; 21\; \&\; 28\; end\{bmatrix\}.$

- $(mathbf\{A\}r)\_\{ij\}\; =\; a\_\{ij\}\; cdot\; r.\; ,$

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

- $$

i & 0

0 & jend{bmatrix} = begin{bmatrix}

-1 & 0

0 & kend{bmatrix} ne begin{bmatrix}

-1 & 0

0 & -kend{bmatrix} = begin{bmatrix}

i & 0

0 & jend{bmatrix}i.

For two matrices of the same dimensions, we have the Hadamard product, also known as the entrywise product and the Schur product. It can be generalized to hold not only for matrices but also for operators. 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} = a_{ij} b_{ij}. For instance

- $$

1 & 2

3 & 1end{bmatrix} bullet begin{bmatrix}

0 & 3

2 & 1end{bmatrix} = begin{bmatrix}

1cdot 0 & 2cdot 3

3cdot 2 & 1cdot 1end{bmatrix}

= begin{bmatrix}

0 & 6

6 & 1end{bmatrix} .

Note that the Hadamard product is a submatrix of the Kronecker product (see below).

The Hadamard product is commutative.

The Hadamard product is studied by matrix theorists, and it appears in lossy compression algorithms such as JPEG, 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

- $$

vdots & vdots & ddots & vdotsa_{m1}B & a_{m2}B & cdots & a_{mn}B end{bmatrix}.

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

- $$

1 & 2

3 & 1end{bmatrix} otimes begin{bmatrix}

0 & 3

2 & 1end{bmatrix} = begin{bmatrix}

1cdot 0 & 1cdot 3 & 2cdot 0 & 2cdot 3

1cdot 2 & 1cdot 1 & 2cdot 2 & 2cdot 1

3cdot 0 & 3cdot 3 & 1cdot 0 & 1cdot 3

3cdot 2 & 3cdot 1 & 1cdot 2 & 1cdot 1end{bmatrix}

= begin{bmatrix}

0 & 3 & 0 & 6

2 & 1 & 4 & 2

0 & 9 & 0 & 3

6 & 3 & 2 & 1end{bmatrix} .

If A and B represent linear transformations V_{1} → W_{1} and V_{2} → W_{2}, respectively, then A B represents the tensor product of the two maps, V_{1} V_{2} → W_{1} W_{2}.

All three notions of matrix multiplication are associative:

- $mathbf\{A\}\; (mathbf\{B\; C\}\; )\; =\; (mathbf\{A\; B\}\; )\; mathbf\{C\}$

and distributive:

- $mathbf\{A\}\; (mathbf\{B\}\; +\; mathbf\{C\}\; )\; =\; mathbf\{A\; B\}\; +\; mathbf\{AC\}$

and

- $(mathbf\{A\}\; +\; mathbf\{B\}\; )\; mathbf\{C\}\; =\; mathbf\{A\; C\}\; +\; mathbf\{B\; C\}$.

and compatible with scalar multiplication:

- $c\; (mathbf\{A\; B\}\; )\; =\; (c\; mathbf\{A\}\; )\; mathbf\{B\}$

- $(mathbf\{A\}\; c\; )\; mathbf\{B\}\; =\; mathbf\{A\}\; (c\; mathbf\{B\}\; )$

- $(mathbf\{A\; B\}\; )\; c\; =\; mathbf\{A\}\; (mathbf\{B\}\; c\; )$

Note that these three separate couples of expressions will be equal to each other only if the multiplication and addition on the scalar field are commutative, i.e. the scalar field is a commutative ring. See Scalar multiplication above for a counter-example such as the scalar field of quaternions.

- $mathbf\{A\}:mathbf\{B\}=sum\_isum\_j\; A\_\{ij\}\; B\_\{ij\}\; =\; operatorname\{trace\}(mathbf\{A\}^T\; mathbf\{B\})\; =\; operatorname\{trace\}(mathbf\{A\}\; mathbf\{B\}^T).$

- Cracovian (for another matrix product)
- Strassen algorithm (1969)
- Winograd algorithm (1980)
- Coppersmith–Winograd algorithm (1990)
- Logical matrix
- Matrix chain multiplication
- Matrix inversion
- Composition of relations
- Basic Linear Algebra Subprograms
- Matrix addition
- Dot product

- Henry Cohn, Robert Kleinberg, Balazs 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.
- Coppersmith, D., Winograd S., Matrix multiplication via arithmetic progressions, J. Symbolic Comput. 9, p. 251-280, 1990.
- Horn, Roger; Johnson, Charles: "Topics in Matrix Analysis", Cambridge, 1994.
- Knuth, D.E., The Art of Computer Programming Volume 2: Seminumerical Algorithms. Third Edition, 1998. pp 501.
- .
- R. Raz. 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.

- The Simultaneous Triple Product Property and Group-theoretic Results for the Exponent of Matrix Multiplication
- WIMS Online Matrix Multiplier
- Matrix Multiplication Problems
- Matrix Multiplication in C
- Linear algebra: matrix operations Multiply or add matrices of a type and with coefficients you choose and see how the result was computed.

Wikipedia, the free encyclopedia © 2001-2006 Wikipedia contributors (Disclaimer)

This article is licensed under the GNU Free Documentation License.

Last updated on Friday September 26, 2008 at 11:52:53 PDT (GMT -0700)

View this article at Wikipedia.org - Edit this article at Wikipedia.org - Donate to the Wikimedia Foundation

This article is licensed under the GNU Free Documentation License.

Last updated on Friday September 26, 2008 at 11:52:53 PDT (GMT -0700)

View this article at Wikipedia.org - Edit this article at Wikipedia.org - Donate to the Wikimedia Foundation

Copyright © 2014 Dictionary.com, LLC. All rights reserved.