# Multiplication of matrices

← Back: Addition of matrices |
Overview: Matrices |
Next: Determinant of a matrix → |

There are exercises as selftest for this article. |

Two matrices can be multiplied if the number of colums of the left matrix equals the number of rows of the right matrix. The result of the multiplication of an l-by-m matrix with an m-by-n matrix is an l-by-n matrix . To calculate the components of the resulting matrix, the components of one row of the first matrix are multiplied with the components of one column of the second matrix respectively and summed up. For example for the component the components of row of the first matrix are multiplied with the components of column of the second matrix. This leads to the following equation for the components of :

A clear possibility to compute the resulting matrix is the pattern of Falk. Thereto the first matrix is noted and on the right over it the second matrix . Then the row vectors of and the column vectors of lead to l times n intersections which correspond to the l-by-n result matrix . The l times n components are determined by computing the dot product of the crossing row vector of and column vector of :

For example the multiplication of a 2-by-3 matrix with a 3-by-2 matrix results in a 2-by-2 matrix and is computed as follows:

As it holds that , the order of a matrix product is important. To specify the order, two types of multiplication are distinguished, pre- and post-multiplication. Pre-multiplying a matrix by matrix means, that is written on the left side of the matrix product: . If matrix is post-multiplied by matrix , is written on the right side: .

Some further rules for matrix multiplications are:

Example: Multiplication of matrices
A good example for the multiplication of several matrices in the context of robotics and transformations is presented in the robotics script. Please have a look in chapter 3 on page 3-35 |

### Multiplication of matrices with vectors

A vector is a just special form of a matrix with either only one row or one column. Because an l-by-m matrix can only be multiplied by an m-by-n matrix, there are two possibilities of multiplying matrices and vectors. The first possibility is a 1-by-m row vector multiplied with an m-by-n matrix which results in a 1-by-n row vector:

The second possibility is a l-by-m matrix multiplied with an m-by-1 column vector which results in a l-by-1 column vector:

Example: Multiplication of matrices and vectors
In chapter 3 of the robotics script some examples of matrices multiplied with vectors appear. On page 3-28 a two-dimensional transformation equation is presented for a rotation about about the origin (see figure) in combination with a translation. The equation uses homogeneous coordinates. The resulting vector is the following: This means that the new coordinates and after the transformation are: |