# Matrix multiplication

This lecture introduces matrix multiplication, one of the basic algebraic operations that can be performed on matrices.

## Inner product

Before defining matrix multiplication, we need to introduce the concept of inner product of two vectors.

Definition Let be a row vector and a column vector. Denote their entries by and by , respectively. Then, their inner product is

Note that in the above definition the order of the product matters, that is is not the same as , because the first vector () needs to be a row vector, and the second one () needs to be a column vector. Furthermore, the inner product is defined only if and have the same number of entries ().

Example Let be a vector defined byand a vector defined byTheir inner product is

## Matrix product

We are now ready to define matrix product.

Definition Let be a matrix and a matrix. Then, their product is a matrix whose -th entry is equal to the inner product between the -th row of and the -th column of , for and .

In other words, the -th entry of is

Note that the order of the product matters, that is is not the same as . Furthermore, the number of columns of needs to be equal to the number of rows of (in which case the two matrices are said to be conformable for the multiplication ).

The next diagram summarizes the dimensions involved in matrix multiplication:

Example Define the matrixand the matrix They are conformable for the multiplication because the number of columns of is equal to the number of rows of . The dimension of the matrix is . The product iswhere, for example, the -th entry of has been obtained from the inner product of the second row of with the first column of :

## Motivation

Why is matrix multiplication defined in this way? There are many possible answers to this question, but the simplest one has to do with the need of obtaining a simple matrix representation for systems of linear equations. The next example shows how.

Example Consider the following system of two equations in two unknowns: This can be represented in matrix form aswhere the matrix of coefficients isthe vector of unknowns isand the vector of constants isYou can easily check that the two ways of writing the system of equations are equivalent by performing the matrix multiplication

Another reason why matrix multiplication is defined in the manner shown above is that it allows to easily deal with input-output systems in which given outputs can be obtained from fixed combinations of inputs.

Example A factory can produce two goods, denoted by and , using different combinations of two inputs, and . In particular, units of and unit of are needed to produce a unit of , and unit of and units of are needed to produce a unit of . This information can be summarized by the input-output matrixwhere the two rows correspond to the two outputs and the two columns correspond to the two inputs. Each unit of costs dollars, and each unit of costs dollar. This information can be summarized by the vector of pricesIn order to find the costs of producing the two outputs, it suffices to perform the following matrix multiplicationSo, both outputs have a production cost of dollars.

## Properties of matrix multiplication

As we have already said, unlike multiplication of real numbers, matrix multiplication does not enjoy the commutative property, that is, is not the same as . However, some of the properties enjoyed by multiplication of real numbers are also enjoyed by matrix multiplication.

Proposition (distributive property) Matrix multiplication is distributive with respect to matrix addition, that is,for any matrices , and such that the above multiplications and additions are meaningfully defined.

Proof

Let and be matrices, and a matrix. Let us start with the productDenote a generic -th element of the matrix by , and a generic -th element of the product between and by . By the definitions of matrix addition and matrix multiplication, we have thatThis holds for any -th element of the matrix. therefore, we have that

With an almost identical argument it is possible to prove that

Proposition (associative property) Matrix multiplication is associative, that is,for any matrices , and such that the above multiplications are meaningfully defined.

Proof

Suppose has dimension , has dimension , and has dimension . Associativity holds because a generic -th element of the matrix is

## Other properties

Other properties of matrix products are listed here.

### Transpose of a product

Proposition Let be a matrix and a matrix. Let and be their transposes. Then,

Proof

The -th entry of is the inner product of the -th row of and the -th column of :By the definition of matrix transpose, the latter is equal to the -th entry of :The -th entry is the inner product of the -th row of and the -th column of : Since the -th row of is equal to the -th column of , and the -th column of is equal to the -th row of :Thus,for any and . Therefore,

## Solved exercises

Below you can find some exercises with explained solutions.

### Exercise 1

Define a matrixand a matrixCompute the product .

Solution

The dimensions involved in this multiplication are summarized in the following diagram:Thus, is a matrix such that for each and , the -th element of is equal to the inner product between the -th row of and the -th row of :

### Exercise 2

Given the matrices and defined above, compute the product .

Solution

The matrices and are not conformable for the multiplication because the number of columns of is not equal to the number of rows of . Therefore, multiplication cannot be carried out.

### Exercise 3

Define a column vectorand a row vectorCompute the product .

Solution

The dimensions involved in this multiplication are summarized in the following diagram:Thus, is a matrix. It is computed as follows: Note that each element of is the product of a row of with a column of . But the rows of are scalars, because is a column vector, and the columns of are also scalars, because is a row vector. As a consequence, each element of is obtained as the product of two scalars.

The book

Most of the learning materials found on this website are now available in a traditional textbook format.

Glossary entries
Share