Matrices
Matrices
Ryan C. Daileda
1 Terminology
A matrix is a rectangular array of numbers, for example
√ 1 0
1 1/2 1/3 1/4
1 5 7 3 −1 0 1
, or 1/2
, , 1/3 1/4 1/5 .
−2 −7 −5 0 2 2 −3
1/3 1/4 1/5 1/6
−7 9
The numbers in any matrix are called its entries. The entries of a matrix are organized into rows and
columns, which are simply the horizontal and vertical (resp.) lists of entries appearing in the matrix. For
example, if
1 0 2 0 −3
M = 0 4 0 5 0
−6 0 7 0 8
then the rows of M are 1 0 2 0 −3 , 0 4 0 5 0 and −6 0 7 0 8 whereas the
columns of M are
1 0 2 0 −3
0 , 4 , 0 , 5 , and 0 .
−6 0 7 0 8
It is worth noting that an m × n matrix will have m rows with n entries each, and n columns with m entries
each. That is, the number of entries in any row of a matrix is the number of columns of that matrix, and
vice versa. This is readily apparent in each of the examples above.
The dimensions of a matrix are the numbers of rows and columns it has. If a matrix has m rows and n
columns we say that it is an m × n matrix (note that we always list the number of rows first). So, the first
four matrices above have dimensions 2 × 3, 2 × 2, 4 × 2 and 3 × 4, respectively. The dimensions of the matrix
M are 3 × 5. An m × n matrix is called square if m = n. Thus, the only example of a square matrix above
is the second.
So that we can more easily refer to various entries in matrices, we index the columns of a matrix from
left to right and the rows from top to bottom. For example, the first column of M (above) is
1
0 ,
−6
1
etc. The first row of M is 1 0 2 0 −3 , the second row is 0 4 0 5 0 and the third row is
−6 0 7 0 8 . We can use this numbering scheme to easily refer to entries in a matrix: we call the
entry located in row i and column j the i, j-entry. For the matrix
1 3 4
−1/6 0 −5
B=
2 −1 7
1/4 2/3 9
the 1, 1-entry is 1, the 3, 2-entry is −1, the 4, 3-entry is 9 and the 2, 1-entry is −1/6.
To write down a matrix with variable entries we use variables with subscripts that indicate their position
in the matrix, using the convention described above. A generic m × n matrix can therefore be denoted
a11 a12 a13 · · · a1n
a21 a22 a23 · · · a2n
A= . (1)
.. .. .. ..
.. . . . .
am1 am2 am3 · · · amn
and is called a row vector. When we use the word vector with no qualification we will usually mean a column
vector. Column vectors give us another shorthand for writing down generic matrices. Notice that if we use
the matrix A in (1) and set
a11 a12 a13 a1n
a21 a22 a23 a2n
a1 = . , a2 = . , a3 = . , · · · , an = .
.. .. .. ..
cm1 cm2 cm3 cmn
(i.e. we use the entries in the j-th column of A as the entries in aj ) then we can write
A = a1 a2 a3 · · · an .
In a similar way one can also use the rows of A to express A in terms of row vectors, but since we won’t be
using this idea later we won’t bother to write it out.
cA = (caij ).
2
That is, cA is the matrix obtained by multiplying every entry of A by c. As examples, if
1 2 0 3 −6
A= ,B=
3 4 2 5 −1
then
2 4 0 0 1 0 3/2 −3 0 −3 6
2A = , 0A = , B= , − B = (−1)B = .
6 8 0 0 2 1 5/2 −1/2 −2 −5 1
Adding two matrices is also done entry-by-entry. If A = (aij ) and B = (bij ) are two m × n matrices, then
their sum is A + B = (aij + bij ). That is, the i, j-entry of A + B is the sum of the i, j-entries of A and B. It
is important to note that is is only possible to add two matrices if they have exactly the same dimensions.
Here’s an example: if
6 5 0 −1
A = 3 4 , B = −2 3
2 1 4 1
then
6 4
A+B = 1 7
6 2
and
12 15
2A − 5B = 16 −7 .
−16 −3
The following theorem summarizes the main properties of matrix addition. The proofs of these properties
follow directly from the definitions made so far and are left to the reader. We will find it useful to be able
to refer to the m × n zero matrix, which is the matrix all of whose entries are zero.
Theorem 1. Let A, B and C be m × n matrices, let c be a real number and let 0 denote the m × n zero
matrix. Then
1. A + B = B + A;
2. A + (B + C) = (A + B) + C;
3. 0 + A = A + 0 = A;
4. c(A + B) = cA + cB;
5. 0A = 0;
3 Matrix multiplication
Defining the matrix product is a two step process. First we will define what it means to multiply a matrix
by a column vector and then we’ll use that to tell us how two multiply matrices in general. Let A be an
m × n matrix and let v be an n × 1 column vector (notice that the vector v has as many entries as A has
columns). Write A in terms of its columns as above,
A = a1 a2 a3 · · · an
3
The product of A with v is defined to be
v1
v2
v3
Av = a1 a2 a3 ··· an = v1 a1 + v2 a2 + v3 a3 + · · · + vn an .
..
.
vn
In words, we multiply the columns of A by the respective entries of v and then add the results together.
According to this definition, the product of an m × n matrix and an n × 1 column vector is an m × 1 column
vector, i.e. the product is a column with as many entries as A has rows.
The process of multiplying a matrix by a vector is straightforward enough once one is used to the
definition. Let’s look at some examples. Suppose that we take
6 5
0 3 −6 5
A= 3 4 ,B= .
2 5 −1 0
2 1
The matrix A can only be multiplied by column vectors with 2 entries while B can only be multiplied by by
column vectors with 4 entries. So, if we take
2
3 0
v= ,w=
−1 −5
1
then
6 5 6 5 13
3
Av = 3 4 = 3 3 − 4 = 5
−1
2 1 2 1 5
and
2
0 3 −6 5 0
= 2 0 + 0 3 − 5 −6 + 5 35
Bw = =
2 5 −1 0 −5 2 5 −1 0 9
1
Since we can now multiply matrices by (suitably sized) column vectors, we can develop a way to multiply
matrices by other (suitably sized) matrices. Let A be an m × n matrix and let B be a n × p matrix. Notice
that B has as many rows as A has columns. In particular, the columns of B are n × 1 column vectors and
can therefore individually be multiplied by A. To be more specific, write B in terms of its columns:
B = b1 b2 b3 · · · bp
That is, to multiply two matrices simply multiply the first matrix by the columns of the second and use the
results as the columns in a new matrix. Since each Aj is an m × 1 column vector, and there are exactly p of
them, we find that AB is an m × p matrix.
Let’s look at a quick example. Take
1 0 −1 3 5
A = 0 −3 2 , B = 2 −1 .
1 2 4 1 3
4
The product AB makes sense since A has as many columns as B has rows. The definition of matrix
multiplication says that
3 5
AB = A 2 A −1 .
1 3
We find that
3 1 0 −1 2
A 2 = 3 0 + 2 −3 + 2 = −4
1 1 2 4 11
and
5 1 0 −1 2
A −1 = 5 0 − −3 + 3 2 = 9
3 1 2 4 10
so that
2 2
AB = −4 9 .
11 10
The n × n identity matrix I is the (square) matrix all of whose entries are zero except for those along the
“main diagonal” which are all equal to 1. Symbolically
1 0 0 ··· 0
0 1 0
··· 0
I= 0 0 1
··· 0 .
.. .. .. .. ..
. . . . .
0 0 0 ··· 1
respectively.
The following theorem gives the main properties of matrix multiplication. These all follow directly
from the definitions, but some are harder to prove than others, most notably that matrix multiplication is
associative.
Theorem 2. Let A be m × n, B and C be n × p, D be p × q, and let c be a real number. Then
1. A(B + C) = AB + AC;
2. (B + C)D = BD + CD;
3. (AB)D = A(BD);
5
4 Exercises
In exercises 1 and 2, let
5 0
−6 3 −4 0 −5
A= , B = −7 −3 ,C= ,
0 0 −6 −3 9
−9 0
5 0 −2
−8 1 6
D= 3 −8 7 , E =
4 −3 0
6 −1 −6
and compute each matrix sum or product if it is defined. If it is not defined, explain why.
Exercise 1.
a. A − B
b. A − 3E
c. 2A + DB
d. AC
Exercise 2.
a. A + CB
b. 3BC − A
c. CAD
d. CA − E
2 1 0 3 9 1
Exercise 3. If A = ,B = ,C = show that AB 6= BA but that
3 −2 −4 1 3 5
AC = CA.
−2 1
Exercise 4. If A = , construct a nonzero 2 × 2 matrix B (with two distinct columns) so that
4 −2
AB is the zero matrix.