<<Up     Contents

Matrix multiplication

This article gives an overview of the various ways to multiply matrices.

The Einstein summation convention is used throughout.

Table of contents

Ordinary matrix product

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 AB is an m-by-p matrix given by

(AB)ij = AirBrj = ai1 * b1j + ai2 * b2j + ... + ain * bnj

for each pair i and j.

The following picture shows how to calculate the (AB)12 element of AB if A is a 2x4 matrix, and B is a 4x3 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.

Matrix multiplication diagram.PNG
<math>(AB)_{12} = \sum_{r=1}^4 a_{1r}*b_{r2} = a_{11}*b_{12}+a_{12}*b_{22}+a_{13}*b_{32}+a_{14}*b_{42}
</math>

Example

<math>
  \begin{bmatrix}
     1 & 0 & 2 \\ 
     -1 & 3 & 1
  \end{bmatrix}
\times
  \begin{bmatrix} 
    3 & 1 \\ 
    2 & 1 \\ 
    1 & 0
  \end{bmatrix}
</math>
<math>

\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 0) \end{bmatrix}

\begin{bmatrix} 5 & 1 \\ 4 & 2 \end{bmatrix}</math>

This notion of multiplication is important because 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.

In general, matrix multiplication is not commutative, ie AB is not equal to BA.

Hadamard product

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)[i,j]=A[i,j] * B[i,j]. For instance

<math>
  \begin{bmatrix}
    1 & 3 & 2 \\ 
    1 & 0 & 0 \\ 
    1 & 2 & 2
  \end{bmatrix}
\cdot
  \begin{bmatrix} 
    0 & 0 & 2 \\ 
    7 & 5 & 0 \\ 
    2 & 1 & 1
  \end{bmatrix}

\begin{bmatrix} 1 \times 0 & 3 \times 0 & 2 \times 2 \\ 1 \times 7 & 0 \times 5 & 0 \times 0 \\ 1 \times 2 & 2 \times 1 & 2 \times 1 \end{bmatrix}

  \begin{bmatrix} 
    0 & 0 & 4 \\ 
    7 & 0 & 0 \\ 
    2 & 2 & 2
  \end{bmatrix}
</math>

Note that the Hadamard product is a submatrix of the Kronecker product (see below). Hadamard product is studied by matrix theorists, but it is virtually untouched by linear algebraists.

Kronecker product

For any two arbitrary matrices A=(aij) and B, we have the direct product or Kronecker product A DirectProduct.png B defined as

<math>
  \begin{bmatrix} 
    a_{11}B & a_{12}B & \cdots & a_{1n}B \\ 
    \vdots & \vdots & \cdots & \vdots \\ 
    a_{n1}B & a_{n2}B & \cdots & a_{mn}B
  \end{bmatrix}
</math>

(the HTML entity ⊗ (&otimes;) represents the direct product, but is not supported on older browsers)

Note that if A is m-by-n and B is p-by-r then A DirectProduct.png B is an mp-by-nr matrix. Again this multiplication is not commutative.

For example

<math>
  \begin{bmatrix} 
    1 & 2 \\ 
    3 & 1 \\ 
  \end{bmatrix}
\otimes
  \begin{bmatrix} 
    0 & 3 \\ 
    2 & 1 \\ 
  \end{bmatrix}

\begin{bmatrix} 1\times 0 & 1\times 3 & 2\times 0 & 2\times 3 \\ 1\times 2 & 1\times 1 & 2\times 2 & 2\times 1 \\ 3\times 0 & 3\times 3 & 1\times 0 & 1\times 3 \\ 3\times 2 & 3\times 1 & 1\times 2 & 1\times 1 \\ \end{bmatrix}

  \begin{bmatrix} 
    0 & 3 & 0 & 6 \\ 
    2 & 1 & 4 & 2 \\
    0 & 9 & 0 & 3 \\
    6 & 3 & 2 & 1
  \end{bmatrix}
</math>.

If A and B represent linear transformations V1W1 and V2W2, respectively, then A DirectProduct.png B represents the tensor product of the two maps, V1 DirectProduct.png V2W1 DirectProduct.png W2.

Common properties

All three notions of matrix multiplication are associative

A * (B * C) = (A * B) * C
and distributive:
A * (B + C) = A * B + A * C
and
(A + B) * C = A * C + B * C
and compatible with scalar multiplication:
c(A * B) = (cA) * B = A * (cB)

Scalar multiplication

The scalar multiplication of a matrix A=(aij) and a scalar r gives the product

rA=(r aij).

If we are concerns with matrices over a ring, then the above multiplicaion is sometimes called the left multiplication while the right multiplication is defined to be

Ar=(aij 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

<math>
  i\begin{bmatrix} 
    i & 0 \\ 
    0 & j \\ 
  \end{bmatrix}

\begin{bmatrix} -1 & 0 \\ 0 & k \\ \end{bmatrix} \ne \begin{bmatrix} -1 & 0 \\ 0 & -k \\ \end{bmatrix}

\begin{bmatrix}
    i & 0 \\
    0 & j \\
  \end{bmatrix}i
</math>

External links

wikipedia.org dumped 2003-03-17 with terodump