Topic 15 Matrices
Topic 15 Matrices
6 Matrices 177
18. Show that if A and B are sets |A| = |B|, then |P (A)| = 33. Use the Schröder-Bernstein theorem to show that (0, 1)
|P (B)|. and [0, 1] have the same cardinality
19. Show that if A, B, C, and D are sets with |A| = |B| and 34. Show that (0, 1) and R have the same cardinality. [Hint:
|C| = |D|, then |A × C| = |B × D|. Use the Schröder-Bernstein theorem.]
20. Show that if |A| = |B| and |B| = |C|, then |A| = |C|. 35. Show that there is no one-to-one correspondence from
21. Show that if A, B, and C are sets such that |A| ≤ |B| and the set of positive integers to the power set of the set of
|B| ≤ |C|, then |A| ≤ |C|. positive integers. [Hint: Assume that there is such a one-
to-one correspondence. Represent a subset of the set of
22. Suppose that A is a countable set. Show that the set B is positive integers as an infinite bit string with ith bit 1 if i
also countable if there is an onto function f from A to B. belongs to the subset and 0 otherwise. Suppose that you
23. Show that if A is an infinite set, then it contains a count- can list these infinite strings in a sequence indexed by the
ably infinite subset. positive integers. Construct a new bit string with its ith
24. Show that there is no infinite set A such that |A| < |Z+ | = bit equal to the complement of the ith bit of the ith string
ℵ0 . in the list. Show that this new bit string cannot appear in
25. Prove that if it is possible to label each element of an the list.]
infinite set S with a finite string of keyboard characters, ∗ 36. Show that there is a one-to-one correspondence from the
from a finite list characters, where no two elements of S set of subsets of the positive integers to the set real num-
have the same label, then S is a countably infinite set. bers between 0 and 1. Use this result and Exercises 34 and
26. Use Exercise 25 to provide a proof different from that 35 to conclude that ℵ0 < |P (Z+ )| = |R|. [Hint: Look at
in the text that the set of rational numbers is countable. the first part of the hint for Exercise 35.]
[Hint: Show that you can express a rational number as a ∗ 37. Show that the set of all computer programs in a partic-
string of digits with a slash and possibly a minus sign.] ular programming language is countable. [Hint: A com-
∗ 27. Show that the union of a countable number of countable puter program written in a programming language can be
sets is countable. thought of as a string of symbols from a finite alphabet.]
∗ 38. Show that the set of functions from the positive inte-
28. Show that the set Z+ × Z+ is countable.
gers to the set {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} is uncountable.
∗ 29. Show that the set of all finite bit strings is countable.
[Hint: First set up a one-to-one correspondence between
∗ 30. Show that the set of real numbers that are solutions of the set of real numbers between 0 and 1 and a subset of
quadratic equations ax 2 + bx + c = 0, where a, b, and c these functions. Do this by associating to the real number
are integers, is countable. 0.d1 d2 . . . dn . . . the function f with f (n) = dn .]
∗ 31. Show that Z+ × Z+ is countable by showing that ∗ 39. We say that a function is computable if there is a com-
the polynomial function f : Z+ × Z+ → Z+ with puter program that finds the values of this function. Use
f (m, n) = (m + n − 2)(m + n − 1)/2 + m is one-to- Exercises 37 and 38 to show that there are functions that
one and onto. are not computable.
∗ 32. Show that when you substitute (3n + 1)2 for each occur- ∗ 40. Show that if S is a set, then there does not exist an onto
rence of n and (3m + 1)2 for each occurrence of m in the function f from S to P (S), the power set of S. Con-
right-hand side of the formula for the function f (m, n) clude that |S| < |P (S)|. This result is known as Cantor’s
in Exercise 31, you obtain a one-to-one polynomial func- theorem. [Hint: Suppose such a function f existed. Let
tion Z × Z → Z. It is an open question whether there is T = {s ∈ S | s ∈ f (s)} and show that no element s can
a one-to-one polynomial function Q × Q → Q. exist for which f (s) = T .]
2.6 Matrices
Introduction
Matrices are used throughout discrete mathematics to express relationships between elements
in sets. In subsequent chapters we will use matrices in a wide variety of models. For instance,
matrices will be used in models of communications networks and transportation systems. Many
algorithms will be developed that use these matrix models. This section reviews matrix arithmetic
that will be used in these algorithms.
178 2 / Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
DEFINITION 1 A matrix is a rectangular array of numbers. A matrix with m rows and n columns is called
an m × n matrix. The plural of matrix is matrices. A matrix with the same number of rows
as columns is called square. Two matrices are equal if they have the same number of rows
and the same number of columns and the corresponding entries in every position are equal.
1 1
EXAMPLE 1 The matrix 0 2 is a 3 × 2 matrix.
▲
1 3
We now introduce some terminology about matrices. Boldface uppercase letters will be
used to represent matrices.
The ith row of A is the 1 × n matrix [ai1 , ai2 , . . . , ain ]. The j th column of A is the m × 1
matrix
a1j
a2j
·
· .
·
amj
The (i, j )th element or entry of A is the element aij , that is, the number in the ith row and
j th column of A. A convenient shorthand notation for expressing the matrix A is to write
A = [aij ], which indicates that A is the matrix with its (i, j )th element equal to aij .
Matrix Arithmetic
The basic operations of matrix arithmetic will now be discussed, beginning with a definition of
matrix addition.
DEFINITION 3 Let A = [aij ] and B = [bij ] be m × n matrices. The sum of A and B, denoted by A + B, is
the m × n matrix that has aij + bij as its (i, j )th element. In other words, A + B = [aij + bij ].
The sum of two matrices of the same size is obtained by adding elements in the corresponding
positions. Matrices of different sizes cannot be added, because the sum of two matrices is defined
only when both matrices have the same number of rows and the same number of columns.
EXAMPLE 2
1 0 −1 3 4 −1 4 4 −2
We have 2 2 −3 + 1 −3 0 = 3 −1 −3.
▲
3 4 0 −1 1 2 2 5 2
2.6 Matrices 179
We now discuss matrix products. A product of two matrices is defined only when the number
of columns in the first matrix equals the number of rows of the second matrix.
DEFINITION 4 Let A be an m × k matrix and B be a k × n matrix. The product of A and B, denoted by AB, is
the m × n matrix with its (i, j )th entry equal to the sum of the products of the corresponding
elements from the ith row of A and the j th column of B. In other words, if AB = [cij ], then
In Figure 1 the colored row of A and the colored column of B are used to compute the element
cij of AB. The product of two matrices is not defined when the number of columns in the first
matrix and the number of rows in the second matrix are not the same.
We now give some examples of matrix products.
EXAMPLE 3 Let
1 0 4
2 4
2 1 1
A= and B = 1 1 .
3 1 0
3 0
0 2 2
Find AB if it is defined.
▲
8 2
Matrix multiplication is not commutative. That is, if A and B are two matrices, it is not
necessarily true that AB and BA are the same. In fact, it may be that only one of these two
products is defined. For instance, if A is 2 × 3 and B is 3 × 4, then AB is defined and is 2 × 4;
however, BA is not defined, because it is impossible to multiply a 3 × 4 matrix and a 2 × 3
matrix.
In general, suppose that A is an m × n matrix and B is an r × s matrix. Then AB is defined
only when n = r and BA is defined only when s = m. Moreover, even when AB and BA are
a11 a12 ... a1k
a21 a22 ... a2k
b11 b12 . . . b1j . . . b1n c11 c12 ... c1n
. .. .. b21
.. . b22 . . . b2j . . . b2n c21 c22 ... c2n
.
= .
ai1
aik ... .. .. .. .. ..
.
ai2 ...
. . . .. . cij .
.. .. .. bk1 bk2 . . . bkj . . . bkn cm1 cm2 ... cmn
. .
am1 am2 . . . amk
both defined, they will not be the same size unless m = n = r = s. Hence, if both AB and BA
are defined and are the same size, then both A and B must be square and of the same size.
Furthermore, even with A and B both n × n matrices, AB and BA are not necessarily equal, as
Example 4 demonstrates.
EXAMPLE 4 Let
1 1 2 1
A= and B= .
2 1 1 1
Does AB = BA?
3 2 4 3
AB = and BA = .
5 3 3 2
Hence, AB = BA.
▲
Transposes and Powers of Matrices
We now introduce an important matrix with entries that are zeros and ones.
DEFINITION 5 The identity matrix of order n is the n × n matrix In = [δij ], where δij = 1 if i = j and
δij = 0 if i = j . Hence
1 0 ... 0
0 1 ... 0
· · ·
In =
·
.
· ·
· · ·
0 0 ... 1
Multiplying a matrix by an appropriately sized identity matrix does not change this matrix. In
other words, when A is an m × n matrix, we have
AIn = Im A = A.
A0 = I n , Ar = AAA · · · A .
r times
The operation of interchanging the rows and columns of a square matrix arises in many
contexts.
2.6 Matrices 181
1 4
1 2 3
EXAMPLE 5 The transpose of the matrix is the matrix 2 5.
4 5 6
▲
3 6
Matrices that do not change when their rows and columns are interchanged are often im-
portant.
Note that a matrix is symmetric if and only if it is square and it is symmetric with respect to its
main diagonal (which consists of entries that are in the ith row and ith column for some i). This
symmetry is displayed in Figure 2.
1 1 0
EXAMPLE 6 The matrix 1 0 1 is symmetric.
▲
0 1 0
aj i
ai j Zero–One Matrices
A matrix all of whose entries are either 0 or 1 is called a zero–one matrix. Zero–one matrices
FIGURE 2 A are often used to represent discrete structures, as we will see in Chapters 9 and 10. Algorithms
Symmetric Matrix. using these structures are based on Boolean arithmetic with zero–one matrices. This arithmetic
is based on the Boolean operations ∧ and ∨, which operate on pairs of bits, defined by
1 if b1 = b2 = 1
b1 ∧ b2 =
0 otherwise,
1 if b1 = 1 or b2 = 1
b1 ∨ b2 =
0 otherwise.
DEFINITION 8 Let A = [aij ] and B = [bij ] be m × n zero–one matrices. Then the join of A and B is the
zero–one matrix with (i, j )th entry aij ∨ bij . The join of A and B is denoted by A ∨ B. The
meet of A and B is the zero–one matrix with (i, j )th entry aij ∧ bij . The meet of A and B is
denoted by A ∧ B.
1 0 1 0 1 0
A= , B= .
0 1 0 1 1 0
182 2 / Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
▲
We now define the Boolean product of two matrices.
DEFINITION 9 Let A = [aij ] be an m × k zero–one matrix and B = [bij ] be a k × n zero–one matrix. Then
the Boolean product of A and B, denoted by A B, is the m × n matrix with (i, j )th entry
cij where
Note that the Boolean product of A and B is obtained in an analogous way to the ordinary
product of these matrices, but with addition replaced with the operation ∨ and with multiplication
replaced with the operation ∧. We give an example of the Boolean products of matrices.
1 0
1 1 0
A = 0 1 , B= .
0 1 1
1 0
(1 ∧ 1) ∨ (0 ∧ 0) (1 ∧ 1) ∨ (0 ∧ 1) (1 ∧ 0) ∨ (0 ∧ 1)
A B = (0 ∧ 1) ∨ (1 ∧ 0) (0 ∧ 1) ∨ (1 ∧ 1) (0 ∧ 0) ∨ (1 ∧ 1)
(1 ∧ 1) ∨ (0 ∧ 0) (1 ∧ 1) ∨ (0 ∧ 1) (1 ∧ 0) ∨ (0 ∧ 1)
1∨0 1∨0 0∨0
= 0 ∨ 0 0 ∨ 1 0 ∨ 1
1∨0 1∨0 0∨0
1 1 0
= 0 1 1 .
▲
1 1 0
We can also define the Boolean powers of a square zero–one matrix. These powers will
be used in our subsequent studies of paths in graphs, which are used to model such things as
communications paths in computer networks.
2.6 Matrices 183
DEFINITION 10 Let A be a square zero–one matrix and let r be a positive integer. The rth Boolean power of
A is the Boolean product of r factors of A. The rth Boolean product of A is denoted by A[r] .
Hence
A[r] = A A A ··· A.
r times
(This is well defined because the Boolean product of matrices is associative.) We also define
A[0] to be In .
0 0 1
EXAMPLE 9 Let A = 1 0 0. Find A[n] for all positive integers n.
1 1 0
The reader can now see that A[n] = A[5] for all positive integers n with n ≥ 5.
▲
Exercises
1 1 1 3 −1 0 5 6
b) A = ,
1. Let A = 2 0 4 6 . −4 −3 5 −2
1 1 3 7
−3 9 −3 4
a) What size is A? B= .
0 −2 −1 2
b) What is the third column of A?
c) What is the second row of A? 3. Find AB if
d) What is the element of A in the (3, 2)th position? 2 1 0 4
a) A = ,B= .
e) What is At ? 3 2 1 3
2. Find A + B, where 1 −1
3 −2 −1
1 0 4 b) A = 0 1 , B = .
1 0 2
a) A = −1 2 2 , 2 3
0 −2 −3
4 −3
3 −1 −1 3 2 −2
−1 3 5 c) A = ,B= .
0 −2 0 −1 4 −3
B= 2 2 −3 .
−1 5
2 −3 0
184 2 / Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
24. a) Show that the system of simultaneous linear equations 28. Find the Boolean product of A and B, where
a11 x1 + a12 x2 + · · · + a1n xn = b1 1 0
1 0 0 1
0 1
a21 x1 + a22 x2 + · · · + a2n xn = b2 A = 0 1 0 1 and B= .
1 1
.. 1 1 1 1
. 1 0
an1 x1 + an2 x2 + · · · + ann xn = bn .
29. Let
in the variables x1 , x2 , . . . , xn can be expressed as
1 0 0
AX = B, where A = [aij ], X is an n × 1 matrix with A = 1 0 1 .
xi the entry in its ith row, and B is an n × 1 matrix 0 1 0
with bi the entry in its ith row.
b) Show that if the matrix A = [aij ] is invertible (as Find
defined in the preamble to Exercise 18), then the so-
a) A[2] . b) A[3] .
lution of the system in part (a) can be found using the
c) A ∨ A[2] ∨ A[3] .
equation X = A−1 B.
30. Let A be a zero–one matrix. Show that
25. Use Exercises 18 and 24 to solve the system
a) A ∨ A = A. b) A ∧ A = A.
31. In this exercise we show that the meet and join opera-
7x1 − 8x2 + 5x3 = 5
tions are commutative. Let A and B be m × n zero–one
−4x1 + 5x2 − 3x3 = −3 matrices. Show that
a) A ∨ B = B ∨ A. b) B ∧ A = A ∧ B.
x1 − x2 + x3 = 0
32. In this exercise we show that the meet and join opera-
tions are associative. Let A, B, and C be m × n zero–one
26. Let
matrices. Show that
1 1 0 1 a) (A ∨ B) ∨ C = A ∨ (B ∨ C).
A= and B= . b) (A ∧ B) ∧ C = A ∧ (B ∧ C).
0 1 1 0
33. We will establish distributive laws of the meet over the
join operation in this exercise. Let A, B, and C be m × n
Find
zero–one matrices. Show that
a) A ∨ B. b) A ∧ B. c) A B.
a) A ∨ (B ∧ C) = (A ∨ B) ∧ (A ∨ C).
27. Let b) A ∧ (B ∨ C) = (A ∧ B) ∨ (A ∧ C).
34. Let A be an n × n zero–one matrix. Let I be the n × n
1 0 1 0 1 1 identity matrix. Show that A I = I A = A.
A = 1 1 0 and B = 1 0 1 .
0 0 1 1 0 1 35. In this exercise we will show that the Boolean prod-
uct of zero–one matrices is associative. Assume that A
is an m × p zero–one matrix, B is a p × k zero–one
Find matrix, and C is a k × n zero–one matrix. Show that
a) A ∨ B. b) A ∧ B. c) A B. A (B C) = (A B) C.
n
A − B (the difference of A and B): the set containing those i = 1 ai : the sum a1 + a2 + · · · + an
n
elements that are in A but not in B i = 1 ai : the product a1 a2 · · · an
A (the complement of A): the set of elements in the universal cardinality: two sets A and B have the same cardinality if
set that are not in A there is a one-to-one correspondence from A to B
A ⊕ B (the symmetric difference of A and B): the set con- countable set: a set that either is finite or can be placed in
taining those elements in exactly one of A and B one-to-one correspondence with the set of positive integers
membership table: a table displaying the membership of ele-
ments in sets uncountable set: a set that is not countable
function from A to B : an assignment of exactly one element ℵ0 (aleph null): the cardinality of a countable set
of B to each element of A c: the cardinality of the set of real numbers
domain of f : the set A, where f is a function from A to B Cantor diagonalization argument: a proof technique used to
codomain of f : the set B, where f is a function from A to B show that the set of real numbers is uncountable
b is the image of a under f : b = f (a) computable function: a function for which there is a com-
a is a pre-image of b under f : f (a) = b puter program in some programming language that finds its
range of f : the set of images of f values
onto function, surjection: a function from A to B such that uncomputable function: a function for which no computer
every element of B is the image of some element in A program in a programming language exists that finds its
one-to-one function, injection: a function such that the im- values
ages of elements in its domain are distinct continuum hypothesis: the statement there no set A exists
one-to-one correspondence, bijection: a function that is both such that ℵ0 < |A| < c
one-to-one and onto matrix: a rectangular array of numbers
inverse of f : the function that reverses the correspondence matrix addition: see page 178
given by f (when f is a bijection) matrix multiplication: see page 179
f ◦ g (composition of f and g): the function that assigns In (identity matrix of order n): the n × n matrix that has
f (g(x)) to x entries equal to 1 on its diagonal and 0s elsewhere
x (floor function): the largest integer not exceeding x At (transpose ofA): the matrix obtained from A by interchang-
x (ceiling function): the smallest integer greater than or ing the rows and columns
equal to x symmetric matrix: a matrix is symmetric if it equals its trans-
partial function: an assignment to each element in a subset of pose
the domain a unique element in the codomain zero–one matrix: a matrix with each entry equal to either 0 or
sequence: a function with domain that is a subset of the set of 1
integers A ∨ B (the join of A and B): see page 181
geometric progression: a sequence of the form a, ar, ar 2 , . . . , A ∧ B (the meet of A and B): see page 181
where a and r are real numbers A B (the Boolean product of A and B): see page 182
arithmetic progression: a sequence of the form a, a + d,
a + 2d, . . . , where a and d are real numbers RESULTS
string: a finite sequence
empty string: a string of length zero
recurrence relation: a equation that expresses the nth term an The set identities given in Table 1 in Section 2.2
of a sequence in terms of one or more of the previous terms The summation formulae in Table 2 in Section 2.4
of the sequence for all integers n greater than a particular The set of rational numbers is countable.
integer The set of real numbers is uncountable.
Review Questions
1. Explain what it means for one set to be a subset of another 5. a) Define the union, intersection, difference, and sym-
set. How do you prove that one set is a subset of another metric difference of two sets.
set?
b) What are the union, intersection, difference, and sym-
2. What is the empty set? Show that the empty set is a subset metric difference of the set of positive integers and the
of every set. set of odd integers?
3. a) Define |S|, the cardinality of the set S.
6. a) Explain what it means for two sets to be equal.
b) Give a formula for |A ∪ B|, where A and B are sets.
4. a) Define the power set of a set S. b) Describe as many of the ways as you can to show that
b) When is the empty set in the power set of a set S? two sets are equal.
c) How many elements does the power set of a set S with c) Show in at least two different ways that the sets
n elements have? A − (B ∩ C) and (A − B) ∪ (A − C) are equal.