2.1 Matrix multiplication
A matrix,
, is a rectangular array of numbers arranged in rows and columns. (Matrices is the plural of the word matrix.) You will concentrate on two-dimensional situations, and so consider matrices of the form:



In order to multiply two matrices, the number of columns of first matrix should be equal to the number of rows in the second matrix. Matrices of the right shape can be multiplied together as follows:

To calculate
, where
is the element in the i th row and j th column of
, you go along the
th row of
and down the
th column of
, multiplying corresponding elements and adding the results. For two
matrices, this pattern may be visualized as follows:




where the
indicates a matrix element in the new matrix,
, and the arrows show how matrix elements in the old matrices are processed to obtain this. In order to multiply two matrices, the number of columns of first matrix should be equal to the number of rows in the second matrix. In other words, each term
is given by
.
Exercise 3
-
What shape is the result of multiplying a
row matrix by a
square matrix? -
What shape is the result of multiplying a
square matrix by a
row matrix? -
What shape is the result of multiplying a
square matrix by a
column matrix? -
What shape is the result of multiplying a
row matrix by a
column matrix?
Answer
-
The result is a
row matrix. - This operation cannot be performed because the number of columns of first matrix is not equal to the number of rows in the second matrix.
-
The result is a
column matrix. -
The result is a
matrix (i.e. a scalar number).
Exercise 4
Evaluate the following combination of square matrices:

Answer
The product of two matrices is given by:

So, to find the matrix element in row
and column
of the product
, we multiply the elements in row
of
with the corresponding elements in column
of
, and add the results together.
To find the product of three matrices,
, we first evaluate
and then form the product
, taking care to preserve the order of the matrices.
So the solution is




OpenLearn - Introduction to quantum computing
Except for third party materials and otherwise, this content is made available under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 Licence, full copyright detail can be found in the acknowledgements section. Please see full copyright statement for details.