Discrete Maths
Discrete Maths
Template
For
Course Material
2011
Updated
i
KWAME NKRUMAH UNIVERSITY OF SCIENCE AND
TECHNOLOGY, KUMASI
ii
Publisher’s I nform ation
© IDL, 2011
All rights reserved. No part of this book may be reproduced or utilized in any form or by any
means, electronic or mechanical, including photocopying, recording or by any information
storage and retrieval system, without the permission from the copyright holders.
Dean
Institute of Distance Learning
New Library Building
Kwame Nkrumah University of Science and Technology
Kumasi, Ghana
Phone: +233-51-60013
+233-51-61287
+233-51-60023
Fax: +233-51-60014
E-mail: [email protected]
[email protected]
[email protected]
[email protected]
Web: www.idl-knust.edu.gh
www.kvcit.org
ISBN:
Editors:
iii
Publisher’s notes to the Learners:
1. Icons: - the following icons have been used to give readers a quick access to where similar
information may be found in the text of this course material. Writer may use them as and when
necessary in their writing. Facilitator and learners should take note of them.
Time For Activity
Self Assessment
Group Discussion
Read
New Terms
Icon #11 Icon #12 Icon #13 Icon #14 Icon #15
Answer Tips Note/Learning Tip
Pause
Online
Interactive CD
This course material is also available online at the virtual classroom (v-classroom) Learning
Management System. You may access it at www.kvcit.org
iv
Course Writer
Course writer:
Course developer:
v
Acknowledgement
I want to thank the almighty God for the knowledge and power granted me to produce this piece.
I am also grateful to the following persons without whose effort this piece might not have been a reality.
vi
Course Introduction
Discrete Mathematics is essentially that branch of mathematics that does not depend on
limits; in this sense, it is the anti-thesis of Calculus. As computers are discrete object
operating one jumpy, discontinuous step at a time, Discrete Mathematics is the right
framework for describing precisely Computer Science concepts. Elucidate
COURSE OVERVIEW
The course starts with combinatorial analysis. Combinatorial analysis deals with counting
techniques, an important concept in programming design. This is to establish several techniques
for counting large finite sets without actually listing their elements. We expatiate on the
techniques of counting as already treated under permutations and combinations and binomial
expansion which is very much linked with combinations. From binomial, we extend to
multinomial expansion and coefficients.
Since most students are familiar with mathematical relations such as “is a subset of”,” is less
than” and so on, one frequently want to compare or contrast various members of a set by
trying to arrange them in some appropriate order, or perhaps, to group together those with
similar properties. The mathematical framework to describe this kind of organization of sets is
the theory of relations. There are two kinds of relations, equivalence relations and order
relations which we will discuss.
We end the course with basic basic concepts related to graphs and trees which has use in car
navigation system, efficient database, build a boot to retrieve info off WWW, representing
computational models and many other applications.
vii
COURSE OBJECTIVES
1. Count large finite sets without listing them.
2. Have a recurrent relation that can generate infinite sets
3. Understand the mathematical logic behind the use of computer.
4. Use a mathematical framework to organise structures in computer.
COURSE OUTLINE
GRADING
Continuous assessment: 30%
End of semester examination: 70%
RESOURCES
Choose an item.
viii
You will require Click here to enter text.for this course.
To complete this course you would need to accomplish [theory], [number of
laboratory/workshop/ practical/ tutorial] and 3 credits
REFERENCES
1. Kenneth A. Ross and Charles R. B. Wright.(1985), Discrete Mathematics. First Edition,
Prentice – Hall, Inc, Englewood Cliffs, N.J. 07632
2. Seymour Lipschutz and Marc Lars Lipson.(1992), Discrete Mathematics. Second
Edition,McGraw – Hill Inc.
3. Marcel B. Finan, Arkansas Tech University
4. W W L CHEN(1982,2008), Imperial College, University of London.
ix
Table Of Contents
Unit 1 .............................................................................................................................................. 1
FUNDAMENTALS OF COUNTING ...........................................Error! Bookmark not defined.
SESSION 1-1: Elements of Counting ..................................................................................... 2
1-1.1 Sum Rule Principle .......................................................................................................... 2
1-1.2 Product Rule Principle ................................................................................................... 5
SESSION 2-1: Permutation and Combination ..................................................................... 8
2-1.1 Permutation .................................................................................................................... 8
2-1.2 Ordered Sample ............................................................................................................ 10
2-1.3 Combination .................................................................................................................. 12
2-1.4 Tree Diagram ................................................................................................................ 20
Unit 2 ............................................................................................................................................ 24
MULTINOMIAL EXPANSION AND COEFFICIENT .............................................................. 24
SESSION 1-2: Binomial Coefficients ................................................................................... 25
SESSION 2-2: Multinomial Coefficients................................................................................ 31
Unit 3 ............................................................................................................................................ 35
RECURRENCE RELATION AND LINEAR DIFFERENCE METHOD .................................. 35
SESSION 1-3: The Difference Operator .............................................................................. 36
SESSION 2-1: Recurrence Relations -Finite Difference Equations .............................. 42
2-3.1 Recursion...................................................................................................................... 42
2-3.2 Classification of Recurrence Relations ........................................................................ 54
2-3.3 The Homogeneous Case ............................................................................................... 61
2-3.4 The Non-Homogeneous Case....................................................................................... 73
Unit 4 ............................................................................................................................................ 85
BOOLEAN LOGIC ...................................................................................................................... 85
SESSION 1-4: Boolean Algebra and Function ...................................................................... 86
1-4.1 Basic Definitions and Theory....................................................................................... 86
1-4.2 Boolean Expressions and Functions............................................................................. 89
1-4.3 Duality .......................................................................................................................... 95
1-4.4 Representation of Boolean Functions .......................................................................... 98
SESSION 2-4: Logic Gates .................................................................................................... 107
2-4.1 Logic Gates Forms ..................................................................................................... 107
x
2-4.2 Combinations of Gates ............................................................................................... 109
2-4.3 Examples of Circuit.................................................................................................... 113
xi
Unit 1
FUNDAMENTALS OF COUNTING
Introduction
Counting of large finite sets has been on the major hurdles in mathematics. The major goal of
this unit is to establish several techniques for counting large finite sets without actually listing
their elements. There are two basic counting principles used throughout. One involves addition
and the other multiplication.
Learning Objectives
Unit content
1
SESSION 1-1: ELEMENTS OF COUNTING
for any two sets A and B we have the following result known as the
Inclusion- Exclusion Principle
A∪ B = A + B − A∩ B .
Indeed, A gives the number of elements in A including those that are common
A∪ B = A + B .
The first counting principle (Sum Rule Principle ): Suppose some event A can
occur in m ways and a second event B can occur in n ways, and suppose both
events cannot occur simultaneously. Then A or B can occur in m + n ways.
In other words (Sum Rule Principle ): Suppose A and B are disjoints sets.
Then A ∪ B = A + B .
an event A3 can occur in n3 ways, and so on, and suppose no two of the
events can occur at the same time. Then one of the events can occur in
n1 + n2 + n3 + ways.
2
Example 1.1 (The Addition Rule)
A1 ∪ A2 ∪ ... ∪ An = A1 + A2 + ... + An
Solution:
Induction hypothesis: Suppose that for any collection { A1, A2 ,..., An } of pairwise
A1 ∪ A2 ∪ ... ∪ An = A1 + A2 + ... + An .
( A1 ∪ A2 ∪ ... ∪ An ) ∩ An+1 =
( A1 ∩ An+1 ) ∪ ( A2 ∩ An+1 ) ∪ ( An ∩ An+1 ) =
∅
= A1 + A2 + + An + An+1
3
Example 1.2
Solution:
Who knew PASCAL. Then A ∩ B is the group of programmers who knew both
languages. By the Inclusion-Exclusion Principle we have:
A∪ B = A + B − A∩ B .
That is,
33 = 25 + 28 − A ∩ B .
4
1-1.2 Product Rule Principle
Another important rule of counting is the multiplication rule.
The second Rule Principle (Product Rule Principle ): Suppose there is an event
A which can occur in m ways and, independent of this event, there is a second
event B which can occur in n ways. Then combinations of A and B can occur
in mn ways.
In other words (Product Rule P rinciple ): Suppose A and B are finite sets.
Then A × B = A ⋅ B
Clearly, the principle can be stated as: If a decision consists of k steps, where
the first step can be made in n1 different ways, the second step in n2 ways,…,
ways.
For example,
. Tossing a coin has two possible outcomes and tossing a die has six
possible outcomes. Then the combined experiment, tossing the coin and
die together results in 2 × 6 = 12 possible outcomes:
H 1, H 2, H 3, H 4, H 5, H 6, T 1, T 2, T 3, T 4, T 5, T 6
5
Example 1.3
=
b) There are n (=
3)( 4 )( 2 ) 24 ways to choose one of each of the
courses.
2. Suppose Airline A has three daily flights between Kumasi and Accra, and
Airline B has two daily flights between Kumasi and Accra
a) There are n = 3 + 2 = 5 ways to fly from Kumasi to Accra.
b) There =
are n (=
3)( 2 ) 6 ways to fly Airline A from Kumasi to Accra,
and then Airline B from Accra back to Kumasi.
c) There =
are n (=
5 )( 5 ) 25 ways to fly from Kumasi and Accra , and
then back again.
Solution:
outcomes.
6
Example 1.3
Let ∑ ={a, b, c, d } be an alphabet with 4 letters. Let ∑ be the set of all words
2
of length 2 with letters from ∑ . Find the number of all words of length 2
where the letters are not repeated. First use the product rule. List the words by
means of a tree diagram.
Solution:
a b c d
c a c d a b d a b c
b d
7
SESSION 2-1: PERMUTATION AND COMBINATION
2-1.1 Permutation
Any arrangement of a set of n object in a given order is called a permutation of
the objects (taken all at a time). Any arrangement of any r ≤ n of those objects
in a given order is called an r -permutation of n objects or a permutation of the
n objects taken r at a time. In symbol P ( n, r ) , is an ordered selection of r
objects from a given n objects.
a) abcd , bcda, acdb, and dcba are permutations of the four letters (taken all at
a time);
b) bad , adb, cbd , and bca are permutations of the four letters taken three at a
time;
c) ad , cb, da, and bd are permutations of the four letters taken two at a time.
Example 1.4
n!
a) Use the product rule to show that P ( n, r ) =
( n − r )!
b) Find all possible 2 - permutations of the set {1, 2, 3} .
Solution:
a) We can treat a permutation as a decision withr steps. The first step can
be made in n different ways, the second in n − 1 different ways, ..., the r th in
8
n!
That is P ( n, r ) = n ( n − 1)( n − r + 1=
)
( n − r )!
3!
b) P (=
3, 2 ) = 6
( 3 − 2 )!
Example 1.5
How many license plates are there that start with three letters followed by 4
digits (no repetitions)?
Solution:
n (n − 1)(n − 2) × ... × 3 × 2 × 1
n!
(ii) n distinct objects taken r at a time is n Pr or P(n, r ) = , where
(n − r )!
r ≤ n.
(iii) n objects consisting of groups of which n1 of the first group are alike, n2
of the second group are alike and so on for the k th group with nk objects
n!
which are alike is , where n = n1 + n2 + . . . + nk
n1 !. n2 !. n3 ! . . .nk !
n!
= (n − 1)!.
n
9
For example,
CBA.
2. The number of permutations of 10 distinct digits taken two at a time
10!
= 10
P2 = = 10 × 9 = 90.
(10 − 2)!
n ⋅ n ⋅ n n =nr
different ordered samples with replacement of size r.
10
II. Sampling without replacement
Here the element is not replaced in the set S before the next element is
chosen. Thus there are no repetitions in the ordered sample. According,
an ordered sample of sizer without replacement is simply an r −
permutation of the elements in the set S with n elements. Thus there
are
n!
P ( n, r =
) n ( n − 1)( n − 2 )( n − r + 1=)
( n − r )!
different ordered samples without replacement of size r from a
population (set) with n elements. In other words, by the product rule, the
first element can be chosen in n ways, the second in n − 1 ways, and so
on.
Example 1.6
Three cards are chosen in succession from a deck with 52 cards. Find the
number of ways this can be done (a) with replacement (b) without
replacement.
Solution:
a) Since each card is replaced before the next card is chosen, each card
can be chosen in 52 ways. Thus there are
52 ( 52 )( 52
= ) 52=3 140,608
different ordered samples of size r = 3 with replacement.
11
P ( 52,3
= ) 52 ( 52 − 1) ( 52 − ( 3 − 1) )
= 52 ( 52 − 1)( 52 − 3 + 1)
= 52
= ( 51)( 50 ) 132,600
different ordered samples of size r = 3 without replacement.
2-1.3 Combination
Suppose we have a collection of n objects. A combination of these n objects
taken r at a time is any selection of r of the objects without taking order in
account. An r - combination of n objects, in symbol C ( n, r ) , is an unordered
selection of r of the n objects. In other words, an r − combination of a set of n
objects is any subset of r elements. But the number of different ways that r
objects can be ordered is r !. Since there are C ( n, r ) groups of r objects from
a given n objects then the number of ordered selection of r objects from n
given objects is r !C ( n, r ) = P ( n, r ) .Thus
P ( n, r ) n! n
( n, r )
C= = = .
r! r !( n − r )! r
For example, the combinations of the letters a, b, c, d taken three at a time are:
12
Example 1.7
Solution:
P ( 4,3)
C ( 4,3) ⋅ 3! =P ( 4,3) or C ( 4,3) =
3!
table below:
Combinations Permutations
Example 1.8
In how many different ways can a hand of 5 cards be selected from a deck of
52 cards? (no repetition)
13
Solution:
Example 1.9
a) C ( n,0
= ) C ( n,=
n ) 1 and C ( n=
,1) C ( n, n −=
1) n .
b) Symmetry property: C ( n, r ) = C ( n, n − r ) , r ≤ n .
Solution:
b) Indeed, we have
n! n!
C ( n, n −=
r) = = C ( n, r )
( n − r )!( n − n + r )! r !( n − r )!
n! n!
c) C ( n, k=
− 1) + C ( n, k ) +
( k − 1)!( n − k + 1)! k !( n − k )!
n!k n!( n − k + 1)
= +
k !( n − k + 1)! k !( n − k )!
n! ( n + 1)! =
= ( k + n − k + 1=) C ( n + 1, k )
k !( n − k + 1)! ( n + 1 − k )!
14
Example 1.10
1. Find the number m of committees of three that can be formed from eight
people. Each committee is, essentially, a combination of the eight people
take three at a time.
Solution:
8 8 ⋅ 7 ⋅ 6
m C ( 8,3
= = ) = = 56
3 1 ⋅ 2 ⋅3
2. A farmer buys three cows, two pigs, and four hens from a man who has six
cows, five pigs, and eight hens. How many choices does the farmer have?
Solution:
6 5
The farmer can choose the cows in ways, the pigs in ways, and the
3 2
8
hens in ways. Hence altogether he can choose the animals in
4
6 5 8
3 ⋅ 2 ⋅ 4 = 20 ⋅ 10 ⋅ 70 = 14,000 ways
3. Find the number m of ways that 9 toys can be divided between 4 children if
the youngest is to receive 3 toys and each of the others 2 toys.
Solution:
There are C ( 9,3) = 84 ways to first choose 3 toys for the youngest. Then
there are C ( 6,2 ) = 15 ways to choose 2 of the remaining 6 toys for the
oldest. Next, there are C ( 4,2 ) = 6 ways to choose 2 of the remaining 4 toys
for the second oldest. The third oldest receives the remaining 2 toys. Thus,
by the product rule:
= =
m 84 (15)( 6 )(1) 7560
15
Example 1.11
1.11(a) (i) In how many ways can a three-figure integer is formed from
the numbers: 4, 3, 5, 6 and 7 if any number can be used more than once?
Solution:
(i) The first, second and third numbers, each can be chosen in 5 ways. The
total number of ways = 5 × 5 × 5 = 125
= 10 × 9 × 8 × 7 × 6 = 30,240
= 5 × 4 × 3 = 60
= 5 × 4 = 20
Hence the students can answer the questions in the three sections in
= 30,240 × 60 × 20 = 36,288,000
16
and digit can appear only once then number of customers the company can
code is obtained as follows:
1.11(c) In many ways can 4 boys and 2 girls seat themselves in a row if :
Solution:
(i) If we regard the 2 girls as a separate persons (B1 B2 B3 B4 G1G2), then the
number of arrangements of 5 different persons, taken all at a time = 5!
The 2 girls can exchange places and so the required number of ways they can
seat themselves = 5! × 2! = 240
The number of ways the 2 girls can occupy the arrowed places:
B1 B2 B3 B4 = 5
P2 = 5 × 4
The required number of permutations (with the 2 girls not sitting next to each
other) = 4! × 5 × 4 = 480
17
(ii) Consist of at least 1 boy and 1 girl.
Solution:
(i) The number of ways of choosing 2 bys from 6 and 2 girls from 5
6 5
= . = 15 × 10 = 150
2 2
(ii) For the committee to contain at least 1 boy and 1 girl we have
6 5 6 5 6 5
= . + . + .
1 3 2 2 3 1
= 6 (10 ) + 15 (10 ) + 20 ( 5 ) =
130
(ii) Four balls are drawn from a bag of 12 balls of which 7 are blue and 5 are
red. In how many of the possible combinations of 4 balls is at least a red?
Solution:
1 8
= . = 70
1 4
18
6
(β ) The number of ways of selecting 4 parents out of 6 = . The number
4
of ways of selecting the remaining number from the 3 (2 teachers and the
3
principal) =
1
6 3
= . = 15 × 3 = 45
4 1
12
(γ ) The number of ways of forming a 5-member committee =
5
6
The number of ways of selecting 5 parents from 6 =
5
5 7
1R 3B, with number of combinations = = 175
1 3
5 7
2R 2B, with number of combinations = = 210
2 2
5 7
3R 1B, with number of combinations = = 70
3 1
5 7
4R, with number of combinations = = 5
4 0
19
2-1.4 Tree Diagram
A (rooted) tree diagram is a useful to enumerate all the logical possibilities of a
sequence of events where each event can occur in a finite number of ways.
A tree diagram is constructed from left to right and that the number of branches at
each point corresponds to the number of ways the next event can occur.
Example 1.12
c
α (1, c,α )
β (1, c, β )
α ( 2, a,α )
a
β ( 2, a, β )
α ( 2, b,α )
2 b
β ( 2, b, β )
α ( 2, c,α )
c
β ( 2, c, β )
20
That is,
a) There are 11 endpoints; hence the betting can occur in 11 different ways.
b) The betting will stop before the five times are up in only three of the ways.
21
Review Probl
ems
Problem 1.1
a) How many ways can we get a sum of 4 or a sum of 8 when two distinguishable
dice are rolled?
b) Suppose a bookcase shelf has 6 mathematics texts, 3 physics texts, 4 chemistry
texts, and 5 computer science texts. Find the number n of ways a student can
choose: (a) one of the texts ( Ans :18) , (b) one of each type of text ( Ans : 360 )
c) How many ways can we get a sum of 8 when two undistinguishable dice are rolled?
Problem 1.2
a) How many 4 - digit numbers can be formed using the digits, 1,2,· · · ,9 (with
repetitions)? How many can be formed if no digit can be repeated?
b) How many different license plates are there that involve 1,2, or 3 letters followed
a) In how many ways can 4 cards be drawn, with replacement, from a deck of 52
cards?
b) In how many ways can 4 cards be drawn, without replacement, from a deck of 52
cards?
Problem 1.4
In how many ways can 7 women and 3 men be arranged in a row if the three men
must always stand next to each other.
Problem 1.5
eight main dishes as part of the dinner special. How many different
22
combinations of main dishes could you order?
Problem 1.6
There are 12 students in a class. Find the number n of ways that 12 students can take
three different tests if four students are to take each test. ( Ans : 34,650 )
.
ANS. 12C4*8C4*4C4
Problem 1.7
Teams A and B play in a basketball tournament. The team that first wins three
games wins the tournament. Find the number of possible ways in which the
tournament can occur.
Problem 1.8
A woman is at the origin on the x axis and takes a one unit step either to the left
or to the right. She stops if she reaches 3 or −3 , or if she occupies any position,
other than the origin, more than once. Find the number of different paths the
woman can travel.
23
Unit 2
MULTINOMIAL EXPANSION AND COEFFICIENT
Introduction
This unit extends the technique of counting as already treated under permutations and
combinations. It may be recalled that binomial expansion is very much linked with
combinations. We are going to have a short but concise study of multinomial expansion, which
is naturally linked with multinomial coefficients.
Learning Objectives
Unit content
24
SESSION 1-2: BINOMIAL COEFFICIENTS
Choosing a subset of size r out of a set of size n is logically equivalent to
partitioning the set of size n into two subsets, one of size r and the other of size
The coefficients nCr , n ≥ r , r ∈ {0,1,..., n} are called the binomial coefficients of the
binomial expression ( x + y ) , n ∈ Z + .
n
Definition 2.1
n!
n
Cr = (2)
r !( n − r ) !
1→1
1→ 2 →1
1→ 3→ 3→ 1
1→ 4 → 6 → 4 →1
25
The following theorem provides an expansion of ( x + y )
n
where n is a
nonnegative integer.
n
( x + y) ∑ C ( n, r )x n−r y r
=
n
r =0
Proof.
1
1 1−0 0 1 1−1 1
( + ) ∑ C ( n, r )x n−r y r =
= 0 x y + 1 x y =
x+ y
1
x y
r =0
n +1
( x + y) ∑ C ( n + 1, r )x
n +1
= n − r +1
yr .
r =0
Indeed, we have:
( x + y) =( x + y )( x + y ) =x ( x + y ) + y ( x + y )
n +1 n n n
n n
= x ∑ C ( n, r )x y + y ∑ C ( n, r )x n −r y r n−r r
=r 0=r 0
26
n n
=
=r 0=r 0
∑ C ( n, r )x n − r +1
y r + y ∑ C ( n, r )x n −r y r +1
n +1
= ∑ C ( n + 1, r )x
r =0
n − r +1
yr
Example 2.1
Expand ( x + y )
6
using the binomial theorem.
Solution:
( x + y) =
x 6 + 6 x 5 y + 15 x 4 y 2 + 20 x 3 y 3 + 15 x 2 y 4 + 6 xy 5 + y 6
6
Example 2.2
∑ C ( n, r ) = 2 n
n
a) Show that r =0
∑ ( −1) C ( n, r ) =
r
b) Show that
n
r =0
0
27
Solution:
r =0
Example 2.3
Expand ( 2 x − 3)
5
Solution:
5
( 2 x − 3) ∑ Cr ( 2 x ) ( −3)
n−r
=
5 5 r
r =0
5! 5 5 5! 4 4 5! 3 3 5! 2 2
= 2 x + 2 x ( −3) + 2 x (9) + 2 x ( −27 )
5!0! 4!1! 3!2! 2!3!
5! 5!
+ 2 x ( 81) + ( −243)
1!4! 0!5!
= 32 x 5 − 240 x 4 + 720 x 3 − 1080 x 2 + 81x − 243
28
Example 2.4
Solution:
But
7!
C2 ( 2 ) (=
−3) ( 2 ) ( −3)
7 5 2 5 2
5!2!
= 6048
(i) ( 2x − 4 y )
5
(ii) ( 3x + 2 y )
2
(iii) ( 2 − 5xy )
4
3 z + (1 − b ) 3 x − ( 7 + 2 y )
3 3
(iv) (v)
29
2. Find the coefficients of the indicated terms in the given binomial
expressions:
x 9 in ( 2 − x ) y 6 in 3 − 5 (1 − y )
8
(ii) (iv)
19
x19 in ( 3 x + 1) − 2
20
(v)
n n
(i) ∑ (ii) ∑ ( −1) 0.
r n
n
Cr = 2 n Cr =
r =0 r =0
x 2 x3 x 4
7. Show that ln (1 + x ) =x − + − + ...
2 3 4
1 1+ x x3 x5
Hence show that ln =x + + + ...
2 1− x 3 5
30
SESSION 2-2: MULTINOMIAL COEFFICIENTS
Let k1 , k2 , ..., kr be integers satisfying the relation k1 + k2 + ... + kr =
n . Then
n!
n
Ck ,k ,...,k =
1 2 r
k1 !k2 !...kr !
Proof
form the first partition. Next, we choose k2 elements out of the remaining
n n − k1 n − k1 − k2 − k3 n − k1 − k2 ......kr −1 n!
k k ... =
1 2 kr −1 kr k1 !k2 !...kr !
(x + x2 + ... + xr ) =∑
n
1
n
Ck ,k ...,k x1k x2 k ...xr k
1 2 r
1 2 r
k1 , k2 ..., kr
where k1 + k2 ... + kr =
n
31
Example 2.5
Expand ( x + y + z )
3
Solution:
(x + y + z)
3
= 3C3,0,0 x 3 y 0 z 0 + 3C0,3,0 x 0 y 3 z 0 + 3C0,0,3 x 0 y 0 z 3 + 3C2,1,0 x 2 y1 z 0 + 3C2,0,1 x 2 y 0 z1
+ 3C1,2,0 x1 y 2 z 0 + 3C0,2,1 x 0 y 2 z1 + 3C1,0,2 x1 y 0 z 2 + 3C0,1,2 x 0 y1 z 2 + 3C1,1,1 x1 y1 z1
3! 3! 3! 3 3! 2 3! 2
= x3 + y3 + z + x y+ x z
3!0!0! 0!3!0! 0!0!3! 2!1!0! 2!0!1!
3! 3! 3! 3! 3!
+ xy 2 + y2 z + xz 2 + yz 2 + xyz
1!2!0! 0!2!1! 1!0!2! 0!1!2! 1!1!1!
=x3 + y 3 + z 3 + 3 x 2 y + 3 x 2 z + 3 xy 2 + 3 y 2 z + 3 xz 2 + 3 yz 2 + 6 xyz
Example 2.6
6 5 10
Evaluate the following (a) (b) (c)
4, 2, 0 3, 2 5,3, 0, 2
6 6! 6 × 5 × 4 × 3 × 2 ×1
Solution: (a) = = = 15
4, 2, 0 4!2!0! 4 × 3 × 2 ×1× 2 ×1
5 5! 5 × 4 × 3 × 2 ×1
(b) = = = 10
3, 2 3!2! 3 × 2 ×1× 2 ×1
10 10! 10 × 9 × 8 × 7 × 6 × 5 × 4 × 3 × 2 × 1
(c) = = = 2520
5,3, 0, 2 5!3!0!2! 5 × 4 × 3 × 2 × 1× 3 × 2 × 1× 2 × 1
32
Example 2.7 (Previous example)
Find the number m of ways that 9 toys can be divided between 4 children if
the youngest is to receive 3 toys and each of the others 2 toys.
9!
=m = 7560
3!2!2!2!
n n n
1. Show that = =
1 2
n , n n1 n2
( n + 1) ! n! n! n!
= + +
i ! j !k ! (i − 1)! j ! k ! i !( j − 1)! k ! i ! j !( k − 1)!
n
3. Prove that for any n ∈ Z + , ∑
k1 , k2 ,..., kr
n
Ck1 ,k2 ,...,kr = r n
(i ) xyz 5 ( ii ) x2 y 2 z3 ( iii ) x3 z 4
(i ) xyz 2 in ( 2 x − y − z )
4
( ii ) ( )
4
xyz −2 in x − 2 y + 3z −1
( iii ) w3 x 2 yz 2 in ( 2w − x + 3 y − 2 z )
8
( iv ) ( )
6
x11 y 4 z 2 in 2 x 3 − 3 xy 2 + z 2
(v) x3 y 4 z 5 in ( x − 2 y + 3 z )
12
33
6. The letters B,C,E,E,N,R,S,S,Y,Z,Z,Z,Z are arranged at random.
Determine the probability that these letters will spell the word
SZCZEBRZESZYN
n c b n n − a n − b
=
c b a a b − a c − b
(ii) Use the interpretation of the binomial coefficients directly as the number
of subsets of a given size.
(iii) Generalize the above formula to answer the question: In how many ways
can one choose an a -element subset from a b -element subset from a c -
element subset from a d -element subset from an n -element set, where
a ≤b ≤ c ≤ d ≤ n?
34
Unit 3
RECURRENCE RELATION AND LINEAR DIFFERENCE
METHOD
Introduction
Welcome to this unit. Any equation involving several elements of a sequence is called a
recurrence relation. Here, we shall learn more about recurrence relations, or simply put,
algorithms. This would entail one, two or three expressions that would generate an infinite set
of numbers. On the other hand, given a set of recurrence relations, a solution would be found
for such a relation.
Learning Objectives
Unit content
35
SESSION 1-3: THE DIFFERENCE OPERATOR
The difference operator ∆ is defined by ( ∆y )( n )= y ( n + 1) − y ( n ) . This is called
d
Familiar properties of carry over as follows:
dx
Linearity
∆ ( y + v ) = ∆y + ∆v; ∆ (α y ) = α∆ ( y ) , α scalar
Product Rule:
( ∆ ( y ⋅ v ) ) ( n )= y ( n + 1) v ( n + 1) − y ( n ) v ( n )
= y ( n + 1) − y ( n ) v ( n + 1) + y ( n ) v ( n + 1) − v ( n )
=( ∆y )( n ) v ( n + 1) + y ( n )( ∆v )( n )
Exponential:
If y ( n )= 2n , ( ∆y )( n )= y ( n + 1) − y ( n )
= 2n +1 − 2n
= 2=
n
f (n)
that is ∆y =y
Thus 2n for difference equations plays the same role e x does for differential
equations.
36
Constants:
∆ ⋅ c = 0, c constant
y 0, that is ( ∆y )( n=
Conversely, suppose that ∆= ) y ( n + 1) − y ( n=) 0 for all n , then
y is a constant.
Theorem
n n
∑ v ( r )= ∑ ( ∆y )( r )= y ( r ) m = y ( n + 1) − y ( m ) .
n +1
If ∆y= v, then
=r m=r m
Proof
We have
v ( n )= y ( n + 1) − y ( n )
v ( n − 1=
) y ( n ) − y ( n − 1)
v ( n − 2 )= y ( n − 1) − y ( n − 2 )
v ( m + 1)= y ( m + 2 ) − y ( m + 1)
v ( m=
) y ( m + 1) − y ( m )
......................................................
n
∑ v ( r )=
r =m
y ( n + 1) − y ( m )
37
Example 3.1
Exponentials:
∆a n = a n +1 − a n = a n ( a − 1) , a constant
Hence
∆a n an
a = = ∆ ( by linearity )
n
a −1 a −1
n
1 n a n +1 − a m
∴ ∑= a r
∑ ∆=a r
=r m= a −1r m a −1
Example 3.2
Polynomials:
fr ( n =
) n ( n − 1)( n − 2 )...( n − r + 1)
Then, ∆f r (n=
) yr (n + 1) − yr (n)
∴∆f r ( n ) =
( n + 1) n ( n − 1)( n − 2 )...( n − r + 2 ) − n ( n − 1)( n − 2 )...( n − r + 1)
= n ( n − 1) ...( n − r + 2 ) ( n + 1) − ( n − r + 1)
= rn ( n − 1)( n − 2 ) ...( n − r + 2 )
= rf ( n )
r −1
This is analogous to
d n
dx
( )
x = nx n −1 .
38
n
1
We may easily deduce that ∑f =
(s)
s =m
r −1
r
f r ( n + 1) − f r ( m ) .
n
1
∑ yr ( s )
So in particular=
s =0 r +1
yr +1 ( n + 1) , if m = 0 .
For example,
n n
∑ s3 = ∑ s3
=s 1 =s 0
n
= ∑ s ( s − 1)( s − 2 ) + 3s ( s − 1) + s
s =0
n
1 1
= ∑ y ( s ) + 3 y ( s ) + y (=
s )
4
y ( n + 1) + y ( n + 1) + y2 ( n + 1)
3 2 1 4 3
s =0 2
1 1
= ( n + 1) n ( n − 1)( n − 2 ) + ( n + 1) n ( n − 1) + ( n + 1) n
4 2
( n + 1) n n − 1 n − 2 + 4 n − 1 + 2
= ( )( ) ( )
4
1
= n 2 ( n + 1)
2
Example 3.3
Let y ( n ) = na n . [ a , constant]
39
( ∆y )( n ) =
( n + 1) a n +1
− na n
= a + na ( a − 1) =
n +1 n
a n +1 + ( a − 1) y ( n )
1 a n +1
Hence y ( n ) = ( ∆y )( n ) −
a −1 a −1
1 a
= ( ∆y )( n ) − 2 ∆a
n
a −1 ( a − 1)
1 a
=
∆ y (n) − a n
a − 1 ( a − 1)
2
−
a −1 ( a − 1)
2
Example 3.4
Trigonometric Functions:
+ α ) sin ( w ( x + 1) + α ) − sin ( wx + α )
∆ sin ( wx =
= 2sin ( w2 ) cos [ wx + α + w2 ]
Then
∑ 2sin ( ) cos [ wr + α=
+ ]
n
w
2
w
2 sin w ( n + 1) + α − sin α
r =0
so that
sin w ( n + 1) + α − sin α
∑ cos [ wr + α + ] =
n
w
2
r =0 2sin w2
40
w
Setting α = − , we have
2
n sin w ( n + 12 ) + sin w2
∑
r =0
cos wr =
2sin w2
n
A similar formula may be derived for ∑ sin wr .
r =0
∞
1
From your answer to (d), deduce that ∑ n ( n + 2)
n =1
exists and find its value.
( )
n
n
3. Show that ∑=
r
r =1
4
30
( n + 1) 6n3 + 9n2 + n − 1 .
41
SESSION 2-1: FINITE DIFFERENCE EQUATIONS -
RECURRENCE RELATIONS
What we are about to study is the discrete analogue of differential equations. Let an be
inductive or recursive definition, such as, a0 , a1 , a2 ,... ) and then a formula specified as
to how to generate subsequent function values from the starting value (or values).
We shall think of the integer n as the independent variable, and restrict our attention to
real sequences, so that the sequence an is considered as a function of the type
f : ∪ {0} → ; n an
2-3.1 Recursion
A recurrence relation for a sequence a0 , a1 ,... is a relation that defines an in
terms of a0 , a1 ,..., an−1 . The formula relating an to earlier values in the sequence
is called the generating rule. The assignment of a value to one of the a ' s is
called an initial condition.
Example 3.5
1,1,2,3,5,...
is a sequence in which every number after the first two is the sum of the
preceding two numbers. Find the generating rule and the initial conditions.
42
Solution:
Example 3.6
Let n ≥ 0 and find the number sn of words from the alphabet ∑ = {0,1} of
length n not containing the pattern 11 as a subword.
Solution:
the word begins with 0 , then the remaining n − 1 letters can be any sequence of
0' s or 1' s except that 11 cannot happen. If the word begins with 1 then the
next letter must be 0 since 11 cannot happen; the remaining n − 2 letters can
be any sequence of 0' s and 1' s with the exception that 11 is not allowed. Thus
the above two categories form a partition of the set of all words of length n with
letters from ∑ and that do not contain 11 . This implies the recurrence
relation =
sn sn−1 + sn−2 , n ≥ 2
The most basic method for finding the solution of a sequence defined recursively
is by using iteration. The iteration method consists of starting with the initial
values of the sequence and then calculates successive terms of the sequence
until a pattern is observed. At that point one guesses an explicit formula for the
sequence and then uses mathematical induction to prove its validity.
43
Example 3.7
a0 =1
an = an−1 + 2, n ≥ 1
Solution:
a0 = 1
a1 = 1 + 2
a2 = 1 + 4
a3 = 1 + 4
a4 = 1 + 8
Hence, a guess is a=
n 2n + 1 , n ≥ 0 . It remains to show that this formula is
valid by using mathematical induction.
we have an+1 = an + 2 = 2n + 1 + 2 = 2 ( n + 1) + 1 .
44
Example 3.8
=
an an−1 + d , n ≥ 1
Solution:
a=
1 a0 + d
a=
2 a0 + 2d
a=
3 a0 + 3d
a=
4 a0 + 4d
Hence, a guess is a=
n a0 + nd . Next, we prove the validity of this formula by
induction.
45
Example 3.9
an = ran−1 , n ≥ 1
Solution:
a1 = ra0
a2 = r 2 a0
a3 = r 3a0
a4 = r 4 a0
induction.
n +1
Induction step: We must show that an+1 = r a0 . By the definition of an+1 we
have a=
n +1 =
ran r ( ra=
0) r n +1
a0 .
46
Example 3.10
a0 0
an = an+1 + ( n + 1) , n ≥ 1
Solution:
a0 = 0
a1 = 0
a2 = 0 +1
a3 = 0 +1+ 2
a4 = 0 +1+ 2 + 3
n ( n − 1)
an = 0 + 1 + 2 + + ( n − 1) =
2
0 ( 0 − 1)
Basis of induction: a0= 0= = 0.
2
n ( n − 1)
Induction hypothesis: Suppose that an = .
2
47
n ( n + 1)
Induction step: We must show that an +1 = . Indeed,
2
an+=
1 an + n
n ( n − 1)
= +n
2
n ( n + 1)
=
2
Example 3.11
a0 =1
an =2an−1 + n n ≥ 1
Solution:
induction.
48
Induction step: We must show that an+1 = 2
n +1
+ ( n + 1) . If this is so then we will
have 2
n +1
+ ( n + 1)= 2an + n= 2n+1 + 2n + n + 1 . But this would imply that n = 0
which contradicts the fact that n is any nonnegative integer.
Example 3.12
a1 =1
an =
2 ⋅ a n , n ≥ 2
2
Solution:
a1 = 1 a2 = 2
a3 = 2 a4 = 4
a5 = 4 a6 = 4
a7 = 4 a=
8 = a=
15 8
i +1
Hence, for 2 ≤ n < 2 , an = 2 . Moreover, i ≤ log 2 n < i + 1 so that
i i
49
an = 2
log 2 n
,n ≥1
log 2 1
Basis of induction: For n = 1 , a1 = 1= 2 .
log 2 n
Induction hypothesis: Suppose that an = 2 .
log 2 n +1
Induction step: We must show that an+1 = 2 .
an +1= 2 ⋅ a n +1
2
log 2 ( n+1)
= 2
NOTATION:
We write a ( n ) = an , or y ( n ) = yn , n ∈
+
Example 3.13
50
y1 = 3
= yn 4 yn −1 if n > 1
n 1 2 3 4 5 …
yn 3 12 48 192 768 …
Example 3.14
0! = 1
n ( n − 1)! if n ≥ 1
n ! =
A general solution for the recurrence relation is a solution process involving some
arbitrary constants. The initial conditions enable us to find the values of those
arbitrary constants. Sometimes by studying the Fibonacci sequence, an intuition
gives the solution of yn in terms of n .
51
Example 3.15
a1 = 3
a2 = 7
a =−
n 3an −1 2an −2 for n ≥ 3
n 1 2 3 4 5 6 …
an 3 7 15 31 63 127 …
52
=
an 3an −1 − 2an −2
But
=
R.H .S 3an −1 − 2an −2
= 3 ( 2n − 1) − 2 ( 2n −1 − 1)
= 3 ⋅ 2n − 3 − 2n + 2
= 2n ( 3 − 1) − 1
= 2n +1 − 1
= an
= L.H .S
When iteration does not apply, other methods are available for finding explicit
formulas for special classes of recursively defined.
Exercise 3.1
an = 1 ,=
an 3an−1 + 1 , for all n ≥ 2
a=
0 1, a=
n 2n − an−1 , for all n ≥ 2 .
a= ( n − 1) , n ≥ 1.
2an−1 + n − 1 satisfies the explicit formula an =
2
n
53
2-3.2 Classification of Recurrence Relation
A recurrence relation is of first order if an is defined only in terms of an −1 . It is of
where k ∈ is fixed.
Example 3.17 an +1 + an =
n is a recurrence relation of order 1 .
4 5
54
Example 3.18 an +3 + 5an + 2 + 4an +1 + an =
cos n is a recurrence
relation of order 3 .
( )
1/3
Example 3.19 an + 2 + 5 an2+1 + an =
0 is a recurrence relation of
order 2 .
Definition 3.1: The order of a recurrence relation is the difference between the
greatest and lowest sub – scripts of the terms of the sequence in the equation.
55
Remark. The recurrence relation an +3 + 5an + 2 + 4an +1 + an =
cos n can also be
written in the form an + 2 + 5an +1 + 4an + an −1= cos(n − 1). There is no reason why the
term of the sequence in the equation with the lowest subscript should always have
subscript n .
For the sake of uniformity and convenience, we shall in this unit always follow the
convention that the element of the sequence in the equation with the lowest subscript
has subscript n .
We shall first of all consider a few examples. Do not worry about the details.
a=
n ( A + Bn ) 3n
(1)
where A and B are arbitrary constants. Replacing n by ( n + 1) and (n+2) in
the equation, we obtain respectively
56
( A + B ( n + 1) ) 3n+1 =
an +1 = ( 3 A + 3B ) 3n + 3Bn3n ( 2)
and
( A + B ( n + 2 ) ) 3n+2 =
an + 2 = ( 3 A + 3B ) 3n+1 + 3B ( n + 1) 3n+1
which simplifies
( A + B ( n + 2 ) ) 3n+2 =
an + 2 = ( 9 A + 18B ) 3n + 9 Bn3n ( 3)
Combining (1) − ( 3) and eliminating A and B , we obtain the second-order
recurrence relation
an + 2 − 6an +1 + 9an =
0
an = A ( −1) + B ( −2 ) + C 3n ( 4)
n n
A ( −1) + B ( −2 ) − A ( −1) − B ( −2 ) + 3C 3n ( 5)
n +1 n +1
an +1 = + C 3n +1 =
n n
an + 2 = A ( −1) + B ( −2 ) + C 3n + 2 = A ( −1) + 4 B ( −2 ) + 9C 3n ( 6)
n+2 n+2 n n
and
an +3 − 7 an +1 − 6an =
0
57
Note that in these three examples, the expression of an as a function of
n contains respectively one, two and three constants. By writing down one, two
and three extra expressions respectively, using subsequent terms of the
sequence, we are in a position to eliminate these constants.
an + 2 − 6an +1 + 9an =
0
58
has general solution a=
n ( A + Bn ) 3 , where
n
A and B are arbitrary constants.
Suppose that we have the initial conditions a0 = 1 and a1 = 15 . Then we must
have an
an= (1 + 4n ) 3 n
.
s0 ( n ) an + k + s1 ( n ) an + k −1 + + sk ( n ) an =f ( n ) ………….(3.1)
s0 an + k + s1an + k −1 + + sk an =f ( n ) ……………………………(3.2)
59
Linear recurrence relations have the following important properties:
an = san −1
a0 = t
an = san −1
= s ( san −2 )
= s 2 ( san −3 )
= ............
= s n −1a1
= s n a0
60
an =+ s1 yn −1 s2 an −2 for n ≥ 2
a1 = t1
a = t
0 0
on the right-hand side of (3.1) is not identically zero, then we say that the
recurrence relation
s0 ( n ) an + k + s1an + k −1 + ... + sk an =
0 …………………………..(3.3)
is the reduced recurrence relation of (3.2).
(1) (k )
Suppose that an ,..., an are k independent solutions of the recurrence relation
s0 a (1) n + k + s1a=
(1)
n + k −1
+ ... + sk an (1) 0, ..., s0 a ( k ) n + k + =
s1a ( k ) n + k −1 + ...sk an ( k ) 0.
61
We consider the linear combination
a=
n
c1an (1) + ... + ck an ( k ) ………………..(3.4)
where c1 ,..., ck are arbitrary constants. Then an is clearly also a solution of (3.3),
for
= c1 ( s0 an(1+)k + s1an(1+)k −1 + ... + sk an(1) ) + ... + ck ( s0 an( k+)k + s1an( k+)k −1 + ...sk=
an( k ) ) 0.
s0 an + 2 + s1an +1 + s2 an =
0 ……………………….(3.5)
where s0 , s1 , s2 are constants, with s0 ≠ 0 and s2 ≠ 0 . Let us try a solution of
the form
an = λ n ………………………………..(3.6)
where λ ≠ 0 . Then clearly an+1 = λ n+1 and an+ 2 = λ n+ 2 , so that
(s λ0
2
+ s1λ + s2 ) λ n =
0
Since λ ≠ 0 , we must have
s0λ 2 + s1λ + s2 =
0 …………………….(3.7)
62
It follows that (3.6) is a solution of the recurrence relation (3.5) whenever λ
satisfies the characteristic polynomial (3.7). Suppose that λ1 and λ2 are the two
roots of (3.7). Then
Characteristic Polynomial
Since an λ=
= and an λ2n are solutions of the linear recurrence relation, then
n
1
Case II
63
However, if λ1 = λ2 , then (3.8) does not qualify as the general solution of the
an = un λ n ……………………………………….(3.9)
where un is a function of n , and where λ is the repeated root of the
characteristic polynomial (3.7). Then
s0 ( un + 2 − un ) λ n + 2 + s1 ( un +1 − un ) λ n +1 + un ( s0λ 2 + s1λ + s2 ) λ n
= s0 ( un + 2 − un ) λ n + 2 + s1 ( un +1 − un ) λ n +1
It follows that
s0λ ( un + 2 − un ) + s1 ( un +1 − un ) =
0
un + 2 − 2un +1 + un =
0
This implies that the sequence un is an arithmetic progression, so that
un= c1 + c2 n , where c1 and c2 are constants. It follows that the general solution
of the recurrence relation (3.5) in this case is given by
a=
n (c 1
+ c2 n ) λ n
64
where λ is the repeated root of the characteristic polynomial (3.7).
Case III
Since the characteristic equation has real coefficients, the complex roots occur in
conjugate pairs. In other words, if λ= λ1= u + iv is a root of the characteristic
equation with real coefficients, then its complex conjugate λ2= λ 1= u − iv is
an = Aλ1n + Bλ2n = A ( u + iv ) + B ( u − iv )
n n
+ iv ρ ( cosθ + i sin θ ) ,
u= − iv ρ ( cosθ − i sin θ )
u=
Then
a=
n
Aρ n ( cos nθ + i sin nθ ) + B ρ n ( cos nθ − i sin nθ )
=( A + B ) ρ n (cos nθ ) + i ( A − B) ρ n sin nθ
65
Similarly if we substitute A = 2 i , then an = ρ sin nθ is also a
− 12 i and B =
1 n
where ρ =+
u 2 v 2 and θ =
tan −1 uv .
an + 2 + 4an +1 + 3an =
0
has characteristic polynomial λ 2 + 4λ + 3 =0 , with roots λ1 = −3 and λ2 = −1 .
It follows that the general solution of the recurrence relation is given by
an = c1 ( −3) + c2 ( −1)
n n
Example 3.27
Solve
yn =−3 yn −1 2 yn − 2 for n ≥ 2
y2 = 7
y = 3
1
Solution:
( λ − 1)( λ − 2=) λ 1 or =
0 so that = λ 2 . The general solution is yn = c1 ⋅1n + c2 ⋅ 2n .
yn =−1 + 2 ⋅ 2n
= 2n +1 − 1
66
Example 3.28. The recurrence relation
an + 2 − 6an +1 + 9an =
0
has characteristic polynomial λ − 6λ + 9 = 0 , with repeated roots λ = 3 . It
2
a=
n (c
1
+ c2 n ) 3n
Example 3.29
Solve
yn =−6 yn −1 9 yn −2 for n ≥ 1
y1 = 3
y = 5
0
Solution:
( λ=
− 3) = λ 3 ( repeated ) . The general solution is
2
0 so that
yn = c1 ⋅ 3n + c2 n ⋅ 3n .
67
yn =5 ⋅ 3n − 4n ⋅ 3n
= 3n ( 5 − 4n )
an + 2 + 4an =
0
has characteristic polynomial λ2 + 4 =0 , with roots λ1 = 2i and λ2 = −2i . It
follows that the general solution of the recurrence relation is given by
a=
n
b1 ( 2i ) + b2 ( −2i=
n n
(
) 2n b1i n + b2 ( −i )
n
)
π π
n
π π
n
2 2 2 2
nπ nπ nπ nπ
= 2n b1 cos + i sin + b2 cos − i sin
2 2 2 2
nπ nπ
= 2n ( b1 + b2 ) cos + i ( b1 − b2 ) sin
2 2
nπ nπ
= 2n c1 cos + c2 sin
2 2
an + 2 + 4an +1 + 16an =
0
( ) ( )
n n
an = b1 −2 + 2 3i + b2 −2 − 2 3i
68
1 3
n
1 3
n
= 4 b1 − +
n
i + b2 − − i
2 2 2 2
2π 2π
n
2π 2π
n
= 4 b1 cos
n
+ i sin + b2 cos − i sin
3 3 3 3
2nπ 2nπ
= 4n ( b1 + b2 ) cos + i ( b1 − b2 ) sin
3 3
2nπ 2nπ
= 4n c1 cos + c2 sin
3 3
Example 3.32
Solve yn + 2 yn −1 + 2 yn − 2 =
0
Solution:
−2 ± 4 − 8
have the roots: λ = =−1 ± i. Thus λ1 =−1 + i and λ2 =−1 − i .
2
69
y
−1 + i
3π
4
−1 − i
=ρ 2 and θ
= 3π
4 .
( ) ( )
n n
=
Hence, yn A 2 sin 3 n4π + B 2 cos 3 n4π is the general solution.
s0 an + k + s1an + k −1 + ... + sk an =
0 …………………..(3.11)
where s0 , s1 ,..., sk are constants, with s0 ≠ 0 . If we try a solution of the form
70
We shall state the following theorem without proof.
∑ (b )λ ,
s
m j −1
=
an j ,1
+ b j ,2 n + ... + b j ,m n
j
n
j
j =1
an = ( c1 + c2 n + c3n 2 ) ( −1) + ( c4 + c5 n )( −2 )
n n
Example 3.34
Solve
=
yn 7 yn − 2 − 6 yn − 3
y0 =
1, y1 = −2 and y2 =
3
71
Solution:
( λ − 1)( λ − 2 )( λ =
+ 3) =
0 so that λ 1, 2 and − 3 .
5 4 11
Using the initial conditions, c1 =
, c2 =
− and c3 =
.
4 5 20
5 4 n 11
So the solution is yn =− 2 + ( −3) .
n
4 5 20
Example 3.35
yn = − yn −1 + 6 yn −2
y1 = 1
y = 9
0
72
Solution:
gn = − g n −1 + 6 g n −2
g1 = 1
g = 3
0
(c)
Suppose that an is the general solution of the reduced recurrence relation
s0 an + k + s1an + k −1 + ... + sk an =
0 …………………………………(3.14)
73
(c)
so that the expression of an involves k arbitrary constants. Suppose further
( p)
that an is any solution of the non-homogeneous recurrence relation (3.13).
Then
= ( s a( )
0
c
n+k
+ s1an( c+)k −1 + ... + sk an( c ) ) + ( s0 an( +p k) + s1an( +p k) −1 + ... + sk an( p ) )
0 + f (n) =
= f ( n ).
It is therefore reasonable to say that (3.15) is the general solution of the non-
homogeneous recurrence relation (3.13).
(c)
The term an is usually known as the complementary function of the recurrence
( p)
relation (3.13), while the term an is usually known as a particular solution of
( p)
the recurrence relation (3.13). Note that an is in general not unique.
an( p ) .
74
In this section, we are concerned with the question of finding particular solutions
of recurrence relations of the type
s0 , s1 ,...sk
are
const
ants, and where f ( n ) is a given function.
The basic trial forms are given in the table below ( c denotes a constant in the
determined):
75
c A c sin α n A1 cos α n + A2 sin α n
cr n ( r ∈ ) Ar n cn m r n r n ( A0 + A1n + Am r m )
an +2 + 4an +1 + 3an =5 ( −2 ) n
It has been shown in Example 3.26 that the reduced recurrence relation has
complementary function
an( =
p)
A ( −2 )
n
Then
A( 2) −2 A ( −2 )
n +1
anp+1 =− =
n
and
an( +p 2) =A ( −2 ) =4 A ( −2 )
n+2 n
It follows that
76
( 4 A − 8 A + 3 A)( −2 ) =
an( +p 2) + 4an( +p1) + 3an( p ) = − A ( −2 ) =−
5( 2)
n n n
if A = −5 .
Hence
nπ nπ
an + 2 + 4=
an 6cos + 3sin
2 2
It has been shown in Example 3.30 that the reduced recurrence relation has
complementary function
nπ nπ
=an( c ) 2n c1 cos + c2 sin
2 2
For a particular solution, we try
nπ nπ
=an( p ) A1 cos + A2 sin
2 2
Then
nπ π nπ π nπ π nπ π
= A1 cos cos − sin sin + A2 sin cos + cos sin
2 2 2 2 2 2 2 2
nπ nπ
= A2 cos − A1 sin
2 2
and
77
=an( +p 2) A1 cos
( n + 2 )π + A2 sin
( n + 2 )π
2 2
nπ nπ nπ nπ
= A1 cos cos π − sin sin π + A2 sin cos π + cos sin π
2 2 2 2
nπ nπ
=
− A1 cos − A2 sin
2 2
It follows that
nπ nπ nπ nπ
an( +p 2) + 4an(=
p)
3 A1 cos + 3 A2 sin = 6cos + 3sin
2 2 2 2
if A1 = 2 and A2 = 1 .
Hence
nπ nπ nπ nπ
an = an( c ) + an( p ) = 2n c1 cos + c2 sin + 2cos + sin
2 2 2 2
nπ nπ
an + 2 + 4an +1 + 16
= an 4n + 2 cos − 4n +3 sin
2 2
It has been shown in Example 3.31 that the reduced recurrence relation has
complementary function
2nπ 2nπ
=an( c ) 4n c1 cos + c2 sin
3 3
For a particular solution, we try
nπ nπ
=an( p ) 4n A1 cos + A2 sin
2 2
78
Then
an( +p1) =4n +1 A1 cos
( n + 1)π + A sin ( n + 1)π
= n nπ
−
nπ
4 2
4 A cos 4 A sin
2
2 1
2 2 2
and
=
an( +p 2) 4n + 2 A1 cos
( n + 2 )π + A sin ( n + 2 )π
2
2 2
nπ nπ
=
4n −16 A2 cos − 16 A1 sin
2 2
It follows that
nπ nπ
an( +p 2) + 4an( +p1) +=
16an( p ) 16 A2 4n cos − 16 A1 4n sin
2 2
nπ nπ
= 4n + 2 cos − 4n +3 sin
2 2
If A1 = 4 and A2 = 1 . Hence
2nπ 2nπ nπ nπ
an = an( c ) + an( p ) = 4n c1 cos + c2 sin + 4cos + sin
3 3 2 2
Example 3.39.
79
an + 2 + 4an +1 + 3an =12 ( −3) .
n
Solve the recurrence relation
Solution:
λ 2 + 4λ + 3 =0 ⇒ λ =−3, −1
( p)
a= An ( −3)
n
n
Then
and
It follows that
⇒ 6 A ( −3) = 12 ( −3)
n n
⇒ A=
2
Hence
Example 3.40.
80
Consider the recurrence relation
an + 2 − 6an +1 + 9an =
3n
λ 2 − 6λ + 9 =0 ⇒ λ = λ1 = λ2 = 3
For the roots of the polynomial , then k = 2 , so we have the particular solution
as:
an( p ) = An 2 3n
Then
an( +p1) = A ( n + 1) 3n +1 = A ( 3n 2 + 6n + 3) 3n
2
an( +p 2) = A ( n + 2 ) 3n + 2 = A ( 9n 2 + 36n + 36 ) 3n
2
and
It follows that
If A = 1 / 18 .
Hence
(c) ( p) n2 n
a n = a n + an = c1 + c2 n + 3
18
81
=
function would be an n( p) k
( A sin α n + A cosα n ) , where
1 2
A, B are constant
Example 3.41.
nπ
an + 2 + 4an =
2n cos
2
It has been shown in Example 3.30 that the reduced recurrence relation has
complementary function
nπ nπ
=an( c ) 2n c1 cos + c2 sin
2 2
nπ nπ
=an( p ) n 2n A1 cos + A2 sin
2 2
Then
nπ nπ
⇒ an( +p1) =( n + 1) 2n +1 A2 cos − A1 sin
2 2
and
82
( n + 2 )π + A sin ( n + 2 )π
( n + 2 ) 2n+2 A1 cos
an( +p 2) = 2
2 2
nπ nπ
⇒ an( +p 2) =( n + 2 ) 2n + 2 − A1 cos − A2 sin
2 2
It follows that
nπ nπ nπ nπ
( n + 2 ) 2n+2 − A1 cos − A2 sin + 4 n2n A1 cos + A2 sin
an( +p 2) + 4an( p ) =
2 2 2 2
nπ nπ
⇒ an( +p 2) + 4an( p ) = − ( n + 2 ) 2n + 2 + 4n 2n A1 cos + − ( n + 2 ) 2n + 2 + 4n 2n A2 sin
2 2
nπ nπ nπ
=
−2n +3 A1 cos − 2n +3 A2 sin =
2n cos
2 2 2
If A1 = −1 / 8 and A2 = 0 . Hence
nπ nπ n nπ
an = an( c ) + an( p ) = 2n c1 cos + c2 − cos
2 2 8 2
a) an + 2 − 6an +1 =
− 7 an 0 b) an + 2 + 10an +1 +=
25an 0 e) an +3 + 5an + 2 + 12an +1 − 18an =
0
c) an +3 − 6an + 2 + 9an +1 −=
4an 0 d) an + 2 − 4an +1 + =
8an 0
2. For each of the following linear recurrences, write down its characteristic polynomial,
the general solution of the reduced recurrence, and the form of a particular solution to
the recurrence:
83
a) an + 2 + 4an +1 − 5an = 4 b) an + 2 + 4an +1 - 5an = n 2 + n + 1
c) an=
+2
− 2an +1 − 5an cos nπ d) an=
+2
+ 4an +1 + 8an 2n sin ( nπ 4 )
e) a= − 9 an 3 f ) a= − 9an n3n
n
n+2 n+2
g)=
an + 2 − 9an n 3 h) an + 2 −=
6an +1 + 9an 3n
2 n
i) an + 2 − 6an +1 + 9an =3 + 7
n n
(
j) an + 2 + 4an =2n cos nπ
2 )
k) an + 2 + 4an 2 cos nπ
= l) an + 2 + 4an n 2n sin nπ
=
n
Write down the general solution of the recurrence, and then find the solution that
satisfies the given initial conditions:
a) f ( n ) =
24 ( −5 ) ; a0 =
3, a1 =
−1 b) f ( n ) =
16 ( −1) ; a0 =
4, a1 =
n n
2
c) f ( n ) = (
8 ( −1) + 7 n ; a0 =
n
)
5, a1 =
11 d) f ( n ) =
12n 2 − 4n + 10; a0 =
0, a1 =
−10
nπ nπ
e) f ( n ) =
2 cos + 36sin ; a0 =
20, a1 =
3
2 2
84
Unit 4
BOOLEAN ALGEBRA, LOGIC GATES
Introduction
We shall have an insight into the basic mathematical logic behind language of computer usage.
An understanding of this unit will ease up complex structures in the complex language of the
computer. You are encouraged to put in some effort to follow this unit
Learning Objectives
Unit content
85
SESSION 1-4: BOOLEAN ALGEBRA AND FUNCTIONS
Let B be a set on which are defined two binary defined operators, + and ∗ , and a
unary operation, denoted by ' ; let 0 and 1 denote two distinct elements of B . Then the
sextuplet
B, +, ∗, ′, 0, 1
is called a Boolean algebra if the following axioms hold for any elements: a, b, c ∈ B ;
( 2a ) a + ( b ∗ c ) = ( a + b ) ∗ ( a + c ) ( 2 b) a ∗ (b + c ) = ( a ∗ b) + ( a ∗ c )
[B3 ] Identity Laws:
( 3a ) a + 0 =a ( 3b ) a ∗1 =a
[B 4 ] Complement Laws:
( 4a ) a + a′ =
1 ( 4b ) a ∗ a′ =
0
The sextuplet is denoted by B when the operations are understood. The element 0 is
called the zero element, the element 1 is called the unit element, and a ' is called the
complement of a . The results of the operations + and ∗ are called the sum and
product, respectively. We will frequently drop the symbol ∗ and use juxtaposition
instead. Then ( 2b ) and ( 2a ) are written
( 2b ) a ( b + c ) = ab + ac ( 2a ) a + bc = ( a + b )( a + c )
86
The following convention, unless guided by parenthesis, is that ' has precedence over
∗ , and ∗ has precedence over +.
For example
a + b ∗ c means a + ( b + c ) not ( a + b ) ∗ c
a ∗ b ' means a ∗ ( b ) ' and not ( a ∗ b ) '
• '
1 0
0 1
+ 1 0 * 1 0
1 1 1 1 1 0
0 1 0 0 0 0
Example 4.1
87
Solution:
( 0 + 1) = 1
and ( 0 + 1) ' =1' =0
1 ∗ 0 + ( 0 + 1) ' =1 ∗ 0 + 0
= 0+0
=0
The complement, Boolean sum and Boolean product correspond to the logical operators
, ∨ and ∧ respectively, where 0 corresponds to F (false) and 1 to T (true).
88
1-4.2 Boolean Expressions and Boolean Functions
Let B = {0,1} . The variable x is called a Boolean variable if it takes values only from
B . A function
= F : Bn {( x , x ,..., x ) x ∈ B, 1 ≤ i ≤ n} → B
1 2 n i is called a Boolean function
Example 4.2
x y F ( x, y )
1 1 0
1 0 1
0 1 0
0 0 0
as
Each Boolean expression represents a Boolean function. The values of this function are
obtained by substituting 0 and 1 for the variables in the expression.
89
Example 4.3
x y z xy= x ∗ y z' F ( x, y , z )
1 1 1 1 0 1
1 1 0 1 1 1
1 0 1 0 0 0
1 0 0 0 1 1
0 1 1 0 0 0
0 1 0 0 1 1
0 0 1 0 0 0
0 0 0 0 1 1
Two different expressions that represent the same function are called equivalent. For
example, the Boolean expressions: xy, xy + 0, xy ∗ 1 are equivalent.
90
Let F and G be Boolean functions of degree n . The Boolean sum F + G and the
Boolean product F ∗ G are defined by
b ({ f : f : B → A}) =
b ( A)
b( B )
exponentiation, we have . Where b denotes the
Hence, there are 24 = 16 different Boolean functions of degree 2 . That is, we want to
(
find b F : B 2 = B ∗ B = { x1 , x2 } : x1 ∈ B = {0,1} → B . )
91
Identities of Boolean Algebra
There are many identities of Boolean algebra but we provide the most important of
them as displayed in the following table:
Boolean Identities
Identity Name
x+x = x
Idempotent laws
x⋅x =x
x+0= x
Identity laws
x⋅0 =0
x +1 =1 Dominance laws
x⋅0 =0
x + ( y + z) = ( x + y) + z
x ( yz ) = ( xy ) z Associative laws
x + ( yz ) =( x + y ) ( x + z) Distributive laws
x ( y + z ) = xy + xz
92
Example 4.4
Solution:
x y z y+z xy xz x( y + z) xy + xz
1 1 1 1 1 1 1 1
1 1 0 1 1 0 1 1
1 0 1 1 0 1 1 1
1 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0
0 1 0 1 0 0 0 0
0 0 1 1 0 0 0 0
0 0 0 0 0 0 0 0
The identity holds because the last two columns of the table agree. The basic
important identities summarized in the previous table can be used to prove further
identities.
93
Example 4.5
Solution:
The steps used to derive this identity and the law used in each step follows:
94
1-4.3 Duality
Observe that in the table of Boolean Identities, the identities come in pairs (except for
the double complement). To fully explain the relationship between the two identities in
each pair, we use the concept of a dual. The dual of a Boolean expression is obtained
by interchanging Boolean sums and Boolean products and interchanging 0’s and 1’s.
Example 6
Solution:
Interchanging * signs and + signs and interchanging 0’s and 1’s in these expressions
produces their duals. The duals are x + ( y ⋅1) and ( x '+ 0 )( y ' z ) respectively.
95
Example 4.7
duals.
Solution:
1. Find the values of the following expressions
(a ) 1 ⋅ 0′ (b) 1 + 1' (c) 0 '⋅ 0 ( d ) (1 + 0 ) '
2. Find the values, if any, of the Boolean variable x that satisfy the following
equations:
( a ) x ⋅1 0
= (b) x + x 0
= ( c ) x ⋅1 x
= (d ) x ⋅ x ' 1
=
Hint: use tables for x ∈ {0,1}
3. What values of the Boolean variables x and y satisfy xy= x + y ? [Hint: use table]
7. Show that xy '+ yz '+ x ' z = x ' y + y ' z + xz ' . (use tables)
96
Exercise 8-15 deal with the Boolean algebra defined by the Boolean sum and Boolean
product on {0,1}
(a ) 1⊕
= 1 0, 1⊕
= 0 1 1⊕
= 0 1 and 0⊕
= 0 0
(use tables)
(a ) x ⊕ ( y ⊕ z) = ( x ⊕ y) ⊕ z
(b) x + ( y ⊕ z) = ( x + y) ⊕ ( x + z)
(c) x ⊕ ( y + z) = ( x ⊕ y) + ( x ⊕ z)
97
1-4.4 Representation Boolean Functions
Two important problems of Boolean algebra will be examined.
The first problem is: Given the values of a Boolean function, can the function be found?
This problem will be solved by showing that any Boolean function may be represented
by a Boolean sum or Boolean product of the variables and their complements, that is,
every Boolean function can be represented using the three Boolean operators:
⋅, + and ' .
The second problem is: Is there a smaller set of operators that can be used to
represent all Boolean functions? This will be answered by showing that all Boolean
functions can be represented using only one operator.
We use examples to illustrate one important way to find a Boolean expression that
represents a Boolean function.
Example 4.8
98
Table 1
x y z F G
1 1 1 0 0
1 1 0 0 1
1 0 1 1 0
1 0 0 0 0
0 1 1 0 0
0 1 0 0 1
0 0 1 0 0
0 0 0 0 0
Solution:
by taking the Boolean product of x, y ' and z . This product xy ' z has value 1 if and only
x= z= 0 and y= 1 . We can form an expression with these values by taking the Boolean
sum of two different Boolean products. The Boolean product xyz ' has the value 1 if and
only if x= z= 0 and y= 1 . The Boolean sum of these two products xyz '+ x ' yz ' represent
99
Definition
Example 4.9
Solution:
By taking Boolean sums of distinct minterms we can build up a Boolean expression with
a specified set of values. In particular, a Boolean sum of minterms has the value 1
when exactly one of the minterms in the sum has the value 1. Consequently, given a
Boolean function, a Boolean sum of minterms can be formed that has the value 1 when
this Boolean function has the value 1. The minterms in this Boolean sum correspond to
those combinations of values for which the function has the value 1. The sum of
minterms that represents the function is called the sum of products expansion or
the disjunction normal forms of the Boolean function.
100
Example 4.10
Solution:
The first step is to find the values of F . These are found in table 2. The sum-of-
products expansion of F is the Boolean sum of three minterms corresponding to the
three rows of this table that give the value 1 for the function.
Table 2
x y z x+ y z′ ( x + y ) z′ =
F
1 1 1 1 0 0
1 1 0 1 1 1
1 0 1 1 0 0
1 0 0 1 1 1
0 1 1 1 0 0
0 1 0 1 1 1
0 0 1 0 0 0
0 0 0 0 1 0
101
conjugate normal form or product-of-sums expansion of the function. These
expansions can be found from the sum-of-products expansions by taking duals.
Functional Completeness
Every Boolean function can be expressed as a Boolean sum of minterms, which are
Boolean products of Boolean variables or their complements. This shows that every
Boolean function can be represented using the Boolean operations ⋅, + and ' . We
Can we find a smaller set of functionally complete operators? This is achievable if one
of the three operators of this set can be expressed in terms of the other two.
102
Can we find a smaller set of functionally complete operators, namely, a set containing
just one operator? Such sets exist.
1 1 0 ↓ 1 0
1 0 1 1 0 0
0 1 1 0 0 1
= 0 and 1=
11 0 0= 0 0; and ↓ or NOR ( not OR )
1 0=
defined by 1 ↓ 1 = 1 ↓ 0 = 0 ↓ 1 = 0 and 0 ↓ 0 = 1 .
Both of the sets {|} is functionally complete. Since {⋅, '} is functionally complete, all
we need to do is show that both operators ⋅ and ' can be expressed using just |
operator. This is done as follows:
x' = x x
xy = ( x y ) ( x y )
103
Exercise
5. Find the sum-of-products of the Boolean function F ( w, x, y, z ) that has the value
104
6. Find the sum-of-products expansions of the Boolean function F ( x1 , x2 , x3 , x4 , x5 )
that has the value 1 if and only if three or more of the variables x1 , x2 , x3 , x4 , x5
7. Find a Boolean sum containing either x or x ' , either y or y 'and either z or z ' that
8. Find a Boolean product of Boolean sums of literals that has the value 0 if and
only if either x= y= 1 and z= 0, x= z= 0 and y= 1 or x= y= z= 0 (Hint: take the
Boolean product of Boolean sums found in parts (a), (b) and (c) in7).
9. Show that the Boolean sum y1 + y2 + ... + yn , where
= =
yi xi and xi 1 if yi = xi' . This
(a) x + y + z
( b ) x + y ' ( x '+ z )
( c ) ( x + y ') '
( d ) x ' ( x + y '+ z ')
105
13. Express each of the Boolean functions in (12) using the operators ⋅ and ' .
14. Show that
=( a ) x ' x=
x ( b ) xy ( x y )( x y )
(c) ( x x )( y y )
x+ y=
17. Express each of the Boolean functions in (3) using the operator .
18. Express each of the Boolean functions in (3) using the operator ↓ .
106
SESSION 2-4: LOGIC GATES
Combinatorial circuits are constructed using three basic types of elements which we
describe as follows:
x x'
Input Output
II. OR gate: The inputs of this gate are two or more Boolean variables. The output
is the Boolean sum of their values. This is represented by
x x+ y
y
Output
Input
107
III. AND gate: The inputs to this gate are of two or more Boolean variables. The
output is the Boolean product of their values. This is represented by
x
xy
y Output
Input
More inputs are permitted to AND and OR gates. Such situations are shown below
x1
x2
x1 x2 ...xn
...
xn
x1
x2
... x1 + x2 + ... + xn
xn
108
2-4.2 Combinations of Gates
Combination circuits can be constructed using a combination of inverters, OR gates, and
AND gates. When combinations of circuits are formed, some gates may share inputs.
One method is the use of branching to indicate all the gates that use a given input.
x
xy
y
xy + x ' y
x'
x' y
The other method is to indicate this input separately for each gate.
x xy
y
xy + x ' y
x'
x x' y
109
Note also that the output from a gate may be used as input by one or more elements
as shown in the above two diagrams. Note also that the two diagrams represent the
same input and output circuiting.
EXAMPLE 4.11
Solution:
(a)
x x+ y
y
( x + y) x '
x'
x
110
OR
x x+ y
y
( x + y) x '
x'
(b)
x'
x
x ' ( y + z ') '
111
x
(x + y + z)
y
z'
z
112
2-4.3 Examples of Circuit
We give some examples of circuits that perform some useful functions.
Example 4.12
Solution:
Let x = 1 if the first individual votes yes, and x = 0 if he votes no; let y = 1 if the second
votes yes and y = 0 if he votes no; let z = 1 if the third individual votes yes, and z = 0 if
this individual votes no. Then a circuit must be designed that produces the output 1
from the inputs x, y and z when two or more of x, y and z are 1. The
representations of the Boolean function that have these output values are
F ( x, y, z ) = xy + xz + yz or F ( x, y, z ) = xy + xz + xyz + yz .
x xy
x xz
xy + xz + yz
z
y yz
113
Draw the circuit of F ( x, y, z ) = xy + xz + xyz + yz .
Example 3
Sometimes light fixtures are controlled by more than one switch. Circuits need to be
designed so that flipping any one of the switches turns the light on when it is off and
turns the light off when it is on. Design circuits that accomplish this when there are two
switches and when there are three switches.
Solution:
second switch is closed and y = 0 when it is opened. Let F ( x, y ) = 1 when the light is
on and F ( x, y ) = 0 when it is off. We arbitrary decide that the light is on when both
switches are closed, so that F (1,1) = 1 . This determines all the other values of F.
(1, 0 ) F=
When one of the two switches is opened, the light goes off, so F= ( 0,1) 0 .
When the other switch is opened, the light goes on, so that F ( 0, 0 ) = 1 . The following
x y F ( x, y )
1 1 1
1 0 0
0 1 0
0 0 1
114
Then we see that F ( x, y=
) xy + x ' y ' with the following circuit:
x xy
xy + x ' y '
x'
x x' y'
y'
y
We arbitrary specify that the light be on when all three switches are closed, so that
F (1,1,1) = 1 . This determines all the values of F . When one switch is open the light
(1,1, 0 ) F=
goes off, so that F= (1, 0,1) F=
( 0,1,1) 0 .
foregoing analysis.
115
x y z F ( x, y , z )
1 1 1 1
1 1 0 0
1 0 1 0
1 0 0 1
0 1 1 0
0 1 0 1
0 0 1 1
0 0 0 0
116
x xyz
y
z
x xy ' z '
y
xyz + xy ' z '+ x ' yz '+ x ' y ' z
z
x x ' yz '
y
z
x
x' y'z
y
z
Where F =xyz + xy ' z '+ x ' yz '+ x ' y ' z is the sum-of-products expansion.
117
In (1) to (5), find the output of the given circuit.
1 2
x
x
y
y
3 4
x x
y
y
z y
x
x
y
z 5
x
y
z
x
y
118
6. Construct circuits from inverters, AND gates, and OR gates to produce the following
inputs: ( a ) x '+ y; ( b ) ( x + y ) ' x; (c) xyz + x ' y ' z '; (d) ( x '+ z )( y + z ') '
7. Design a circuit that implements majority voting for five individuals. A proposal is
passed if it receives at least three yes votes.
8. Design a circuit for a light fixture controlled by four switches where flipping one of
the switches turns the light on when it is off and turns it off when it is on.
119
Unit 5
RELATIONS AND ORDER IN A SET
Introduction
The reader is familiar with many relations which are used in mathematics
and computer science, i.e. ”is a subset of”, ” is less than” and so on. One frequently
wants to compare or contrast various members of a set, perhaps to arrange them in
some appropriate order or to group together those with similar properties. The
mathematical framework to describe this kind of organization of sets is the theory of
relations.
Learning Objectives
Unit content
120
SESSION 1-5: RELATIONS
A binary relation (or relation) from a set of A to a set B assigns to each pair a, b
∗
Observe that any relation from a set A to a set B uniquely defines a subset of
A × B as follows:
∗
= { a, b : a b}
b iff a, b ∈ ∗
a
Domain
= {a : a , b ∈ }
of
Range
= {b : a, b ∈ }
of
121
1-5.2 Equivalence Relation
Definition
[ E ] If a, b ∈
2
, then b, a ∈ , symmetric property
∗
[ E ] If a, b ∈
3
, and b, c ∈ , then a, c ∈ , transition property
∗ ∗
by . =
A/ {[ a ] : a ∈ A}
Theorem
Then:
( i ) For every a ∈ A, a ∈ [ a ]
( ii ) [ a ] [b], iff a, b ∈
=
( iii ) If [ a ] ≠ [b], then [ a ] and [b] are disjoint
122
A class a of non-empty subsets of A is called a partition of A if and only if
Theorem
Example 5.1
Let 5 be the relation in , the set of integers, defined by x ≡ y ( mod 5 ) , which reads “
Note that the equivalence classes are pairwise disjoint and that
Z = E0 ∪ E1 ∪ E2 ∪ E3 ∪ E4
123
Example 5.2
Consider
= the relation {=
1, 2 , 1,3 , 2,3 } in A {1, 2,3} . Then
Domain of = {1, 2} ,
Range of = {2,3}
Let −1 denote the relation that reverses the pairs in . Then −1 = { 2,1 , 3,1 , 3, 2 } .
We observe that and −1 are identical respectively, to the mathematical relations <
iff a < b, and a, b ∈ −1 iff a < b .
and > in the set A . Thus a, b ∈
The identity relation in any set A , denoted by ∆ or ∆ A , is the set of pairs in A × A with
1. Prove: let be a relation in A , that is ⊂ A × A . Then
(i) is reflexive if and only if ∆ A ⊂
2. Consider
= the relation {=
1,1 , 2,3 , 3, 2 } in X {1, 2,3} . Determine whether or not
124
Prove that is an equivalence relation
4. Consider × , the set of ordered pairs of positive integers. Let be the relation in
× defined by a, b c, d iff a + b = b + c
125
SESSION 2-5: ORDERING OF A SET
a, b, c ∈ A such that
The set A together with the partial order, that is, the pair ( A, ) is called a partially
Example 5.3
Example 5.4
Let A be any set of real numbers. Then the relation in A defined by x y is a partial
126
Example 5.5
Let X = {a, b, c, d , e} . Then the diagram below defines a partial order in X as follows:
x y iff x = y or if one can go from x to y in the diagram, always moving in the indicated
b c
Definition
If ab in an ordered set, we say, a precedes or is smaller than b and that b follows
A particular ordered set A is said to be totally (or linearly) ordered if, for every
a, b ∈ A , either a b or b a .
The set of real numbers, , with the natural order defined by x y is an example of
a totally ordered set.
127
Example 5.6
Let A and B be totally ordered. Then the product set A × B can be totally ordered as
follows: a, b a ', b ' if a a ' or a = a′, and b b ' .
This order is called lexicographical of A × B since it is similar to the way words are
arranged in a dictionary.
REMARKS
128
2-5.2 Subsets of Ordered Sets
Let A be a subset of a partially ordered set X . Clearly the order in X induces an
order in A in a very natural way. If a, b ∈ A , then ab as elements in A if and only if
A
= ∩ ( A × A ) , called the restriction of to A , is a partial order in A . The
ordered set ( A, )
A
is called partially ordered subset of the ordered set ( X , ).
Some subsets of a partially ordered set X may, in fact, be totally ordered. Clearly, if
X itself is totally ordered, every subset of X will also be ordered.
Example 5.7
a b
d e
The sets {a, c, d } and {b, e} are totally ordered subsets, the sets {a, b, c} and {d , e} are
129
2-5.3 First and Last Elements
Let X be an ordered set. An element a0 ∈ X is a first or smallest element of X if and
Example 5.8
b c
Then a is a last element of X since a follows every element. We note that X has no
first element, since d is not a first element because d does not proceed e .
Example 5.9
The positive integers with the natural order have 1 as a first element; there is no last
element. Similarly, the set of integers with the natural order has no first element and
no last element.
130
2-5.4 Maximal and Minimal Elements
Let X be an ordered set. An element a0 ∈ X is maximal if and only if a0 x implies
itself.
Example 5.9
Example 5.10
Although with the natural order is totally ordered it has no minimal and no maximal
elements.
Example 5.11
Let A = {a1 , a2 ,..., am } be a finite totally ordered set. Then A contains precisely one
131
2-5.5 Upper and Lower Bounds
Let A be a subset of a partially ordered set X . An element m ∈ X is a lower bound of
A if and only if m x for all x ∈ A , that is, if m precedes every element in A . If
some lower bound of A follows every other lower bound of A , then it is called the
greatest lower bound (G.L.B) or infimum of A and is denoted by inf ( A ) . Similarly, an
A is said to be bounded above if it has an upper bound, and bounded below if it has a
lower bound. If A has both an upper and lower bounds, then it is said to be bounded.
Example 5.12
a b
c
B
d e
g
f
132
Let B = {c, d , e} . Then a, b and c are upper bound of B , and f is the only lower
bound of B . We note that g is not a lower bound of B since g does not precede d .
Example 5.13
Let A be a bounded set of real numbers. Then, a fundamental theorem about real
numbers states that, under the natural order, inf ( A ) and sup ( A ) exist.
Example 5.14
infinite number of upper and lower bounds, but inf ( B ) and sup ( B ) do not exist,
because the real numbers 2 and 3 do not belong to and therefore cannot be
considered as upper and lower bounds of B .
EXERCISE
Where r , r ', s, s ' ∈ {0,1, 2,3,...} . Let a a ' if r < r or if ' r =r ' but s < s ' .
133
Insert the correct symbol, or
, between each of the following pairs of
numbers. (Note:
x y iff y x ).
all non-empty totally ordered subsets of A , and let Α be partially ordered by set
inclusion. Construct a diagram of the order of Α .
b c
3.=
Let A {=
2,3, 4,...} \ {1} and let A be ordered by " x divides y " .
134
1 2
4 5
6 7
6. Let =
A ( , ≤) , the positive integers with the natural order; and let =
B ( , ≥) ,
the positive integer with the inverse order. Furthermore, let A × B denote the
lexicographical ordering of × according to the order of A and then B . Insert
the correct symbol, < or >, between each pair of elements of × .
( i ) 3,8 .......... 1,1 ( ii ) 2,1 .............. 2,8
( iii ) 3,3 .......... 3,1 ( iv ) 4,9 ............. 7,15
7. Let X = {1, 2,3, 4,5, 6} be ordered as in the diagram below. Consider the subset
A = {2,3, 4} of X .
135
1
3 4
5 6
8. Consider , the set of rational numbers, with the natural order, and its subset
{
A = x : x ∈ , x3 < 3}
(i) Is A bounded above?
(ii) Is A bounded below?
(iii) Does sup ( A ) exist?
9. Let , the positive integers, be ordered by " x divides y " and let A ⊂
136
(ii) Does sup ( A ) exists?
ZORN’S LEMMA
Zorn’s lemma: Let X be a non-empty partially ordered set in which every totally
ordered subset has an upper bound, then X contains at least one maximal element.
[based on respective learning points in learning objective add interactive subject matter;
with examples, exercises with answers, insert captioned illustrations, diagrams, tables,
figures, etc.]
137
Unit 6
ELEMENTS OF GRAPH THEORY
Introduction
In this unit we present the basic concepts related to graphs and trees such as the
degree of a vertex, connectedness, Euler and Hamiltonians circuits.
Learning Objectives
Unit content
138
SESSION 1-6: BASICS OF GRAPHS
1-6.1 Definitions
An undirected graph G consists of a set VG of vertices, points, or nodes
nodes and a set EG of ordered pairs of vertices called arcs or directed edges
Two vertices are said to be adjacent if there is an edge connecting the two
vertices. Two edges associated to the same vertices are called parallel. An edge
incident to a single vertex is called a loop. A vertex that is not incident on any
edge is called an isolated vertex. A graph with neither loops nor parallel edges
is called simple graph.
Example 6.1
A e1 B
e4 e2
e5
C e3 D
Figure 6-1 shows the graph G = G (V , E ) where: (i) V consists of the vertices A ,
B , C , D ; and (ii) E consists of the five edges e1 = { A, B} , e2 = { B, C} ,
e3 = {C , D} , e4 = { A, C} , e5 = { B, D} .
139
Example 6.2
e3 v3
v2 e4
e2 v
v6 •5
e1 v4
e6
v1 e5
v7
a. Find EG and VG .
Solution.
d. {e2 , e3 } .
e. {v2 , v4 } .
f. {e1 , e4 , e5 }
140
Example 6.3
Solution.
b. G is simple.
141
1-6.2 Complete Graph
A complete graph on n vertices, denoted by K n , is the simple graph that
Example 6.4
Draw K 2 , K 3 , K 4 , and K 5 .
Solution.
K2 K3
K4 K5
A graph in which the vertices can be partitioned into two disjoint sets V1 and V2
with every edge incident on one vertex in V1 and one vertex of V2 is called
bipartite graph.
142
Example 6.5
v2
u2
v3
b. Show that K 3 is not bipartite.
Solution:
b. Any two sets of vertices of K 3 will have opposite parity. Thus, according
A complete bipartite graph K m ,n , is the graph that has its vertex set
143
Example 6.6
Solution: v1 u1 v1
u1
v2 u2 v2
u2
v3 u3 v3
K 2,3
K 3,3
144
1-6.3 Degree
The degree of a vertex v in an undirected graph, in symbol deg ( v ) , is the
twice to the degree of that vertex. The total degree of G is the sum of the
Example 6.7
v2
v1•
e1 e2
v3
e3
Solution:
= =
deg(v1 ) 0,deg( =
v2 ) 2,deg( v3 ) 4 .
145
Theorem 6.1
2 | EG | = ∑ deg ( v )
v∈V ( G )
[The sum of the degrees of the vertices of a graph is equal to twice the number
of edges]
Proof:
arbitrarily, this shows that each edge of G contributes 2 to the total degree of
G . Thus,
2| EG | = ∑
v∈V ( G )
deg(v)
146
Theorem 6.2
Proof.
Let G = (VG , EG ) be a graph. By the previous theorem, the sum of all the
the numbers deg(v) , each which is even and O the sum of numbers deg(v)
Example 6.8
Solution:
By Theorem 6.1 n ( n − 1) =
2 | EG |.
147
SESSION 2-6: PATHS AND CIRCUITS
2-6.1 Paths
In an undirected graph G a sequence P of the form v0e1e2 ...vn −1en vn is called a
Example 6.9
In the graph below, determine whether the following sequences are paths,
simple paths, circuits, or simple circuits.
v1 e2 v5
e4
e1 v2
e3 e5
v0 e10
e9 e7
v3 e8 v4
e6
a. v0e1v1e10v5e9v2e2v1 .
b. v3e5v4e8v5e10v1e3v2 .
c. v1e2v2e3v1 .
d. v5e9v2e4v3e5v4e6v4e8v5 .
148
Solution:
a. a path (no repeated edge), not a simple path (repeated vertex v1 ), not a
circuit
b. a simple path
c. a simple circuit
149
2-6.2 Connectivity
An undirected graph is called connected if there is a path between every pair of
distinct vertices of the graph. A graph that is not connected is said to be
disconnected.
Example 6.10
v4 v2 v5 v6
v2 •v3 v5 •v
4
v1 v•6 v1 v3
v8 v7
a b
Solution:
a. Connected.
150
2-6.3 Euler Path and Circuit
A simple path that contains all edges of a graph G is called an Euler path.
Theorem 6.3
If a graph G has an Euler circuit then every vertex of the graph has even
degree.
Proof:
Let G be a graph with an Euler circuit. Start at some vertex on the circuit and
follow the circuit from vertex to vertex, erasing each edge as you go along it.
When you go through a vertex you erase one edge going in and one edge going
out, or else you erase a loop. Either way, the erasure reduces the degree of the
vertex by 2 . Eventually every edge gets erased and all the vertices have degree
0 . So all vertices must have had even degree to begin with.
It follows from the above theorem that if a graph has a vertex with odd
If all the vertices of a connected graph have even degree, then the graph has an
Euler circuit.
151
Example 6.11
v2 e1 v3
e4 e e5 e2
6
e7
v1 v4
e3
Solution:
Vertices v1 and v3 both have degree 3 , which is odd. Hence, by the remark
following the previous theorem, this graph does not have an Euler circuit.
152
2-6.4 Hamiltonian Path and Circuit
A path is called a Hamiltonian path if it visits every vertex of the graph exactly
once. A circuit that visits every vertex exactly once except for the last vertex
which duplicates the first one is called a Hamiltonian circuit.
Example 6.12
w z
x y
Solution:
vwxyzv .
153
Example 6.13
Show that the following graph has a Hamiltonian path but no Hamiltonian
circuit.
y z
Solution:
154
MY PAGE
Name: _______________________________________ Learning Centre: _________________
_____________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
Self-grading: self assessment questions score ______ % Unit Assignments scored ______ %
______________________________________________________________________________
______________________________________________________________________________
155
= = = = = = = = = = = = = = = = = = = = = = = = = detach and return to IDL, KNUST = = = = = = = = = = = = = = = = = = = = Learner Feedback Form/[insert course code]
Dear Learner,
While studying the units in the course, you may have found certain portions of the text
difficult to comprehend. We wish to know your difficulties and suggestions, in order
to improve the course. Therefore, we request you to fill out and send the following
questionnaire, which pertains to this course. If you find the space provided
insufficient, kindly use a separate sheet.
1. How many hours did you need for studying the units
Unit no. 1 2 3 4 5 6
No. of hours
2. Please give your reactions to the following items based on your reading of the
course
Items Excellent Very Good Poor Give specific examples, if
good poor
Presentation
quality
Language and
style
Illustrations
used
(diagrams,
tables, etc.)
Conceptual
clarity
Self assessment
Feedback to SA
Unit 1: _______________________________________________________________
Unit 2: _______________________________________________________________
Unit 3: _______________________________________________________________
Unit 4: _______________________________________________________________
Unit 5: _______________________________________________________________
Unit 6: _______________________________________________________________
156