0% found this document useful (0 votes)
15 views121 pages

Discrete Maths CSM 166-1

Uploaded by

essilfieobed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views121 pages

Discrete Maths CSM 166-1

Uploaded by

essilfieobed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 121

CSM 166: DISCRETE

MATHEMATICS FOR
COMPUTER SCIENCEII

Yao. Elikem.Ayekple

1
Unit1
Fundamentals of Counting
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.

Elements of Counting
Sum Rule Principle
For a set X , X denotes the number of elements of X . It is easy to
see that 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 to A and B . The same holds for B . Hence, A  B


includes twice the number of common elements. Hence, to get an
accurate count of the elements of A  B , it is necessary to subtract
A  B from A  B .

Note that if A and B are disjoint then A  B  0 and consequently

A B  A  B .

2
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 .
Clearly, the principle can be extended to three or more events.
Specifically, suppose an event A1 can occur in n1 ways, an event A2
can occur in n2 ways, 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.

Example 1.1 (The Addition Rule)


Show by induction on n , that if  A1 , A2 ,..., An  is a collection of
pairwise disjoint sets then
A1  A2  ...  An  A1  A2  ...  An

Solution:
Basis of induction: For n  2 the result holds by the Inclusion-
Exclusion Principle.
Induction hypothesis: Suppose that for any collection  A1 , A2 ,..., An  of
pairwise disjoint sets we have
A1  A2  ...  An  A1  A2  ...  An .

3
Induction step: Let  A1 , A2 ,..., An , An1 be a collection of pairwise
disjoint sets.
Since
 A1  A2  ...  An   An1   A1  An1    A2  An1    An  An1   

then by the Inclusion-Exclusion Principle and the induction


hypothesis we have
A1  A2  ...  An  An1  A1  A2  ...  An  An1

 A1  A2    An  An1
Example 1.2
A total of 35 programmers interviewed for a job; 25 knew
FORTRAN, 28 knew PASCAL, and 2 knew neither language. How
many knew both languages?

Solution:
Let A be the group of programmers that knew FORTRAN, B those
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 .

Solving for A  B we find A  B  20 |.

4
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 Principle): 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,…, the k th step in nk ways, then the decision
itself can be made in n1  n2    nk 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
. The number of different ways for a man to get dressed if he has
8 different shirts and 6 different pairs of trousers is 8  6 = 48
. The number of ways a three-figure integer be formed from the
numbers, 4, 3, 5, 6 and 7 if no number is used twice or more is
5  4  3 = 60.

5
Example 1.3
1. Suppose a college has 3 different computer science courses, 4
different mathematics courses, and 2 different actuarial courses
(with no prerequisites)
a) There are n  3  4  2  9 ways to choose 1 of the courses.
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.

3. How many possible outcomes are there if 2 distinguishable dice


are rolled?
4. Suppose that a state’s license plates consist of 3 letters followed
by four digits. How many different plates can be
manufactured?(No repetitions)

6
Solution:
3. By the multiplication rule there are 6  6  36 possible
outcomes.
4. By the multiplication rule there are
26  25  24  10  9  8  7  78,624,000 possible license plates.

Example 1.3
Let   a, b, c, d  be an alphabet with 4 letters. Let  2 be the set of all

words 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:
By the multiplication rule there are 4  3  12 different words.
Constructing a tree diagram:

a b c d

a c d a b d a b c
b c d

we find that the words are:


ab, ac, ad , ba, bc, bd , ca, cb, cd , da, db, dc
Applying the multiplication principle, results in the other two
counting techniques, namely Permutation and Combination, used to
find the number of possible ways when a fixed number of items are to
be picked from a lot without replacement

7
PERMUTATIONS
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.

Consider, for example, the set of letters a, b, c, and d . Then:


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 with r steps. The first step
can be made in n different ways, the second in n  1 different ways,
..., the r th in n   r  1  n  r  1 different ways. Thus, by the

8
multiplication rule there are n  n  1 · · ·  n  r  1 r -
permutations of n objects.
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:
P  26, 3 · P 10, 4   78, 624, 000

An ordered arrangement of objects is called a permutation. The


number of permutations of
(i) n distinct objects, taken all together is n! =
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 ) = ,
( n  r )!
where 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


n!
group with nk objects which are alike is ,
n1 !. n2 !. n3 ! . . .nk !

where n  n1  n2  . . .  nk

9
(iv) n distinct objects arranged in a circle, called circular
permutations is given by

n!
 ( n  1)!.
n
For example,
1. The number of possible permutations of the letters, A, B and
C is 3!  6. The required permutations are ABC, BAC, ACB,
BCA, CAB and CBA.
2. The number of permutations of 10 distinct digits taken two
at a time
10!
 10 P2   10  9  90.
(10  2)!

3. The number of permutations of the letters forming the


following 14- letter word, S C I E N T I F I C A L L Y,
which contains 2C’s, 3I’s, 2L’s, and 1’s of the rest of letters
14!
= 2!.3!.2! = 3,632,428,800

4. The number of circular permutations of 6 persons sitting


around a circular table
= 5! = 120

10
Ordered Samples
When we choose one element after another from the set S containing
n elements, say r times, we call the choice an ordered sample of size
r . We consider two cases:

I. Sampling with replacement


Here the element is replaced in the set S before the next
element is chosen. Since there are n different ways to choose
each element (repetitions are allowed), the product rule
principle tells us that there are
 
r times

n  n  n n  n r
different ordered samples with replacement of size r .

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 size r 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.

11
Example 1.6
Three cards are chosen in succession form 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   523  140,608

different ordered samples of size r  3 with replacement.

b) Since there is no replacement, the first card can be chosen in


52 ways, the second card in 51 ways, and the last card 50
ways. Thus there are
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.

12
COMBINATIONS
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
C  n, r      .
r! r ! n  r !  r 

For example, the combinations of the letters a, b, c, d taken three at a


time are:
a, b, c,a, b, d ,a, c, d ,b, c, d  or simply abc, abd , acd , bcd
Observe that the following combinations are equal:
abc, acb, bac, bca, cab, cba
That is, each denotes the same set a, b, c

13
Example 1.7
Find the number of combinations of four objects, a, b, c, d taken three
at a time.

Solution:
Each combination consisting of three objects determines 3!  6
permutations of the objects in the combination. Thus the number of
combination multiplied by 3! equals the number of permutations. That
is:
P  4,3
C  4,3  3!  P  4,3 or C  4,3 
3!
But P  4,3  4  3  2  24 and 3!  6 . Thus C  4,3  4 , which is
shown in the table below:

Combinations Permutations
abc abc, acb, bac, bca, cab, cba
abd abd , adb, bad , bda, dab, dba
acd acd , adc, cad , cda, dac, dca
bcd bcd , bdc, cbd , cdb, dbc, dcb

Example 1.8
In how many different ways can a hand of 5 cards be selected from a
deck of 52 cards? (no repetition)

Solution:
C  52,5   2, 598, 960

14
Example 1.9
Prove the following identities:
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 .

c) Pascal’s identity: C  n  1, k   C  n, k  1  C  n, k  , n  k .

Solution:
a) Follows immediately from the definition of C  n, r  . Check
yourself.

b) Indeed, we have
n!
C  n, n  r  
 n  r ! n  n  r !
n!

r ! n  r !

 C  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!
  k  n  k  1
k ! n  k  1!


 n  1!  C  n  1, k 
 n  1  k !

15
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  2
3  
8 
ways, and the hens in   ways. Hence altogether he can choose
 4
the animals in
 6 5  8 
 3    2    4   20  10  70  14,000 ways
     

16
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

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?
(ii) In a certain examination paper, students are required to answer
5 out of 10 questions from Section A another 3 out of 5 questions
from Section B and 2 out of 5 questions from Section C. In how many
ways can the students answer the examination paper?

Solution:
(i) The first, second and third numbers, each can be chosen in 5
ways. The total number of ways = 5  5  5 = 125
(ii) The number of ways of answering the questions in Section A
= 10  9  8  7  6 = 30,240

17
The number of ways of answering the questions in section B
= 5  4  3 = 60
The number of ways of answering the questions in section C
= 5  4 = 20
Hence the students can answer the questions in the three sections in
= 30,240  60  20 = 36,288,000

1.11(b) A company codes its customers by giving each customer


an eight character code. The first 3 characters are the letter A, B and C
in any order and the remaining 5 are the digits 1, 2, 3, 4 and 5 also in
any order. If each letter and digit can appear only once then number
of customers the company can code is obtained as follows:
The first 3 letters can be filled in 3!
The next 5 digits can be filled in 5!
Then the required number = 3!  5! = 720

1.11(c) In many ways can 4 boys and 2 girls seat themselves in a


row if :
(i) The 2 girls are to sit next to each other?
(ii) The 2 girls are not to sit next to each other?

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!

18
The 2 girls can exchange places and so the required number of ways
they can seat themselves = 5!  2! = 240
(ii) The number of ways the boys can arrange themselves = 4!
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

1.11(d) Find the number of ways in which a committee of 4 can


be chosen from 6 boys and 5 girls if it must
(i) Consist of 2 boys and 2 girls.
(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
1B3G, 2B2G or 3B1G
The required number of ways
 6 5  6   5   6  5
=  .     .    .  
1   3   2   2 3 1 

= 6 10   15 10   20  5   130

19
1.11(e) (i) A school Parent-Teacher committee of 5 members
is to be formed from 6 parents, 2 teachers and the principal. In how
many ways can the committee be formed in order to include
( ) The principal? ( ) Exactly four parents?
( ) Not more than four parents?
(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:
(i) ( ) If the principal is to be included then we select 4 people
from the remaining 8. Hence required number of ways the committee
is formed
1  8 
=  .    70
1  4 

6
( ) The number of ways of selecting 4 parents out of 6 =   . The
4  
number of
ways of selecting the remaining number from the 3 (2 teachers and
 3
the principal) =  
1  
Therefore the number of ways of selecting exactly 4 parents
 6   3
=   .   = 15  3 = 45
 4  1 

12 
( ) The number of ways of forming a 5-member committee =  
5  

20
 6
The number of ways of selecting 5 parents from 6 =  
5
 
Therefore the required number of ways of selecting a committee with
12  6
not more than 4 parents =      = 126 – 6 = 120
5  5 

(ii) If at least one red is to be included then the combinations


include
 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 

Review Problems
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?

21
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 by 4 - digits (with repetitions)?
Problem 1.3
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
A menu in a Chinese restaurant allows you to order exactly two of
eight main dishes as part of the dinner special. How many different
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 

22
Unit2

MULTINOMIAL COEFFICIENTS
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.

Objectives
On completion of this unit, you should be able to:
 Upgrade your knowledge on advanced techniques on
counting process
 Extend knowledge of binomial expansion to
multinomials
 Solve more practical problems

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
n!
size  n – k  . The number of such partitions if by definition nCr  .
r ! n  r  !

23
Suppose x, y are variable and n  Z  the positive integers, then
n
 x  y   nCr x n r y r  nC0 x n y 0  nC1 x n 1 y1  nC2 x n  2 y 2  ...  nCn x 0 y n
n

r o

The coefficients nCr , n  r , r  0,1,..., n are called the binomial

coefficients of the binomial expression  x  y  , n  Z  .


n

DEFINITION
n!
n
Cr  (2)
r ! n  r  !

Where 0!  1 and n!  n  n  1 n  2  ...1

Pascal’s identity allows one to construct the following triangle known


as
Pascal’s triangle (for n = 5) as follows
1
11
1 2 1
1 3 3 1
1 4  6  4 1

The following theorem provides an expansion of  x  y  where n


n

is a nonnegative integer.

24
Theorem 2.1 (Binomial Theorem)
Let x and y be variables, and let n be a positive integer. Then
n
 x  y   C  n, r x nr y r
n

r 0

where C  n, r  is called the binomial coefficient.


Proof.
The proof is by induction.
Basis of induction: For n  1 we have
1
1  1
   C  n, r x nr y r    x10 y 0    x11 y1  x  y
1
x  y 
r 0 0 1
Induction hypothesis: Suppose that the theorem is true for n .
Induction step: Let us show that it is still true for n  1. That is
n 1
 x  y   C  n  1, r x n r 1 y r .
n 1

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 n r y r  y  C  n, r x n r y r
r 0 r 0

n n
  C  n, r x n  r 1
y  y  C  n, r x n r y r 1
r

r 0 r 0

 C  n,0  x n1  C  n,1 x n y  C  n,2  x n 1 y 2    C  n, n  xy n


 C  n,0  x n y  C  n,1 x n 1 y 2    C  n, n  1 xy n  C  n, n  y n 1

 C  n  1,0  x n 1  C  n  1,1 x n y  C  n  1, 2  x n1 y 2 


   C  n  1, n  x n y  C  n  1, n  1 y n 1
n 1
  C  n  1, r x n r 1 y r
r 0

25
Example
Expand  x  y  using the binomial theorem.
6

Solution:
By the Binomial Theorem and Pascal’s triangle we have

 x  y
6
 x 6  6 x 5 y  15 x 4 y 2  20 x 3 y 3  15 x 2 y 4  6 xy5  y 6

Example

 C  n, r   2 n
n
a) Show that r 0

  1 C  n, r   0
n r
b) Show that r 0

Solution:
a) Letting x  y  1 in the binomial theorem we find
n
2n  1  1   C  n, r 
n

r 0

b) This follows from the binomial theorem by letting x  1 and


y  1

Example
Expand  2 x  3
5

Solution:
5
 2 x  3   5Cr  2 x   3 
5 nr r

r 0

 5C0  2 x   3  5C1  2 x   3  5C2  2 x   3


5 0 4 1 3 2

 5C3  2 x   3  5C4  2 x  3  5C5  2 x   3


2 3 4 0 5

26
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

Example 2
Obtain the coefficient of a 5b 2 in the expansion of  2a  3b 
7

Solution:
To obtain the coefficient of the term a 5b 2 , we notice that in (2), we set
r  2 to obtain
C2  2   -3 as the coefficient of a 5b 2
7 5 2

But
7!
C 2  2   3    2   3 
7 5 2 5 2

5!2!
 6048
Therefore, the coefficient of a 5 b 2 of the binomial expression is 6048

1. Expand the following binomial expressions:


(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)

2. Find the coefficients of the indicated terms in the given binomial


expressions:

27
x12 y13 in  x  y  x12 y13 in  2 x  3 y 
25 25
(i) (ii)

x 9 in  2  x  y 6 in 3  5 1  y  
19 8
(ii) (iv)

x19 in  3 x  1  2 
20
(v)

3. Prove that for any n  Z 


n n

   1
r n
(i) n
Cr  2 n (ii) Cr  0 .
r 0 r 0

4. Using the binomial expression 1  x  to find the approximate values of


n

the following to 5 decimal places:


(i) 0.95 (ii) 1.994
5. Expand 1  2x 
6
and hence evaluate 0.96 to six decimal places.
6. Show that k Ck  k 1Ck  ...  k  r Ck  k  r 1Ck 1
x 2 x3 x 4
7. Show that ln 1  x   x     ...
2 3 4

1  1 x  x 3 x5
Hence show that ln    x    ...
2  1 x  3 5

8. Solve the following


a) Find the coefficient of a 5b 7 in the binomial expansion of (1  2b)12
b) Use the binomial theorem to prove that
n
3n   2r C  n, r 
r 0

28
MULTINOMIAL COEFFICIENTS

Let k1 , k2 , ..., kr be integers satisfying the relation k1  k2  ...  k r  n . Then


The number of ways a set of n elements can be partitioned into classes of
Sizes k1 , k2 , ..., kr equal
n!
k1 !k2 !...kr !

Proof
We obtain the partitioning in steps: First, we choose k1 out of n elements to
form the first partition. Next, we choose k2 elements out of the remaining

 n  k1  elements, and so on until we have n  k1  k2  ...  kr 2  kr 1  kr

elements from which we choose kr 1 to form the next-to-last class. The


remaining kr elements forms the last class. This has been accomplished in

 n   n  k1   n  k1  k2   n  k1  k2  ...  kr  2  n  k1  k2  ...  kr 1 
    ...    ways.
 k1  k2   k3   kr 1  kr 

Simple algebra shows that


 n   n  k1   n  k1  k2  k3   n  k1  k2 ......kr 1  n!
 k   k  ...  
 1  2   kr 1  kr  k1 !k2 !...kr !

Suppose x1 , x2 , x3 ,..., xr are variables and n  Z  , then

 x1  x2  ...  xr  
n
 n
Ck1 ,k2 ...,kr x1k1 x2 k2 ...xr kr
k1 , k2 ..., kr

where k1  k2 ...  kr  n

29
Example 1
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  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

Example (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!

30
n  n  n 
1. Show that   =   =  
 n1 ,n2   n1   n2 

2. Show that if i  1, j  1, k  1 and i  j  k  n  1 , then


  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

4. In the expansion of  x  y  z  find the coefficient of the terms:


7

i  xyz 5  ii  x2 y2 z3  iii  x3 z 4

5. Determine the coefficient of the following terms in the indicated


multinomial expressions.
i  xyz 2 in  2 x  y  z 
4

 
4
 ii  xyz 2 in x  2 y  3z 1

 iii  w3 x 2 yz 2 in  2w  x  3 y  2 z 
8

 
6
 iv  x11 y 4 z 2 in 2 x3  3 xy 2  z 2

v x 3 y 4 z 5 in  x  2 y  3 z 
12

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

7. Show that if a  b  c  n , then


 n c  b  n n  a  n  b
      =      
c  b a a b  a  c  b 

31
(i) Use the definition of binomial coefficients as ratios of factorials.

(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 ?

8. Expand  x  y  z  . Hence with x  y  z  0.3 evaluate 0.96 to six decimal


6

places. (Compare this approximation with that of Q5 of the previous


exercise).

32
Unit3

THEORY OF DIFFERENCE EQUATIONS/RECURRENCE


RELATIONS

INTRODUCTION
Welcome to this unit. 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.

THE DIFFERENCE OPERATOR


The difference operator  is defined by  y  n   y  n  1  y  n  . This is called
the forward difference operator. The difference operator  is the analogous
y  x  h  y  x
of the differential operator in calculus. Indeed, y  x   lim is
h 0 h
the definition of the derivative f   x  of f  x  . Similarly
y  x  h  y  x
 y  x   , when h  1 .
h

d
Familiar properties of carry over as follows:
dx
Linearity
  y  v   y  v;   y     y  ,  scalar

33
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   2 n ,  y  n   y  n  1  y  n 
 2n 1  2n
 2n  f  n 
that is y  y

Thus 2 n for difference equations plays the same role e x does for differential
equations.

Constants:
  c  0, c constant

Conversely, suppose that y  0, that is  y  n   y  n  1  y  n   0 for all n , then

y is a constant.

The operation analogous to integration is that of taking finite sums. The


following result is a discrete version of the fundamental theorem of calculus,
which essentially says that differentiation and integration are inverse
operations.

34
Theorem
n n

 v  r     y  r    y  r    y  n  1  y  m  .
n 1
If y  v, then m
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   y  n  1  y  m 
r m

Example 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  a  1
r

r m a  1 r m
(This is just the usual method for summing a geometric progression).

35
Example 2
Polynomials:
We consider easier polynomials of the form
f r  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 r 1  n 

d n
This is analogous to
dx
 
x  nx n 1 .

n
1
We may easily deduce that  f  s   r  f  n  1  f  m  .
s m
r 1 r r

n
1
So in particular  y  s   r  1 y  n  1 , if m  0 .
s 0
r r 1

With this, we have a method of summation for any polynomial.

For example,
n n

s
s 1
3
  s3
s 0
n
   s  s  1 s  2   3s  s  1  s 
s 0

n
1 1 
   y3  s   3 y2  s   y1  s     y4  n  1  y3  n  1  y2  n  1 
s 0 4 2 

36
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

4
Example 3
Let y  n   na n . [ a , constant]

Using example 1, we study y .


 y  n    n  1 a  na n 1 n

 a  na  a  1  a   a  1 y  n 
n 1 n n 1

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

Then by the theorem,


n
1 a
 y  r   a  1  y  n  1  y  m     a  a 
2 
n 1 m

r m  a  1

 n  1 a  ma m a n  2  a m 1
n 1


a 1  a  1
2

37
Example 4
Trigonometric Functions:
We study this specialized branch of mathematics using forward
differences:

 sin  wx     sin  w  x  1     sin  wx   


 2sin  w2  cos  wx    w
2 
Then
n

 2sin   cos  wr      sin  w  n  1     sin 


r 0
w
2
w
2

so that
n sin  w  n  1     sin 
 cos  wr     
r 0
w
2
2sin w2
w
Setting    , we have
2
n sin  w  n  12    sin w2
 cos wr 
r 0 2sin w2
n
A similar formula may be derived for  sin wr .
r 0

1. Verify the following differences


a  n 2 4n   3n  2  n  2  4n ;
b  3n  n  1 n  2  n  3  4  n  1 n  2  n  3 
 12n  n  2  n  3
nN n 1  N  1 
 c  1     1  
n   n 1 
2n  1 2
d  
n  n  1 n  n  2

38
2. From (1) deduce the value of
n n
a    3r  2  r  2  4r
r 0
b  r  r  2  r  3
r 1
10
15  N
1
 c    1 d 
n
 
n 3 n  n 0 n  n  2 


1
From your answer to (d), deduce that  n  n  2
n 1
exists and find its

value.
n
n
3. Show that r 4

30
 
 n  1 6n3  9n 2  n  1 .
r 1

39
FINITE DIFFERENCE EQUATIONS - RECURRENCE RELATIONS

What we are about to study is the discrete analogue of differential


equations. Let an be a function defined on the set of positive integers.
An inductive or recurrence definition of the function y specifies the
starting value, such as a0 (or several starting values of the 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).

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 2.1
The Fibonacci sequence
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.
Solution:
The initial conditions are a0  a1  1 and the generating rule is
an  an 1  an 2 ; n  2

40
Example 2.2
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:
Clearly, s0  1 (empty word) and s1  2 . We will find a recurrence

relation for sn , n  2 . Any word of length n with letters from 


begins with either 0 or 1 . If 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
A solution to a recurrence relation is an explicit formula for an in
terms of n .

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.

41
Example 2.3
Find a solution for the recurrence relation
 a0 1

 an  an 1  2, n  1
Solution:
Listing the first five terms of the sequence one finds
a0  1
a1  1  2
a2  1  4
a3  1  4
a4  1  8
Hence, a guess is an  2n  1 , n  0 . It remains to show that this
formula is valid by using mathematical induction.

Basis of induction: For n  0, a0  1  2  0   1 .


Induction hypothesis: Suppose that an  2n  1 .

Induction step: We must show that an1  2  n  1  1 . By the

definition of an 1 we have an1  an  2  2n  1  2  2  n  1  1 .

Example 2.4
Consider the arithmetic sequence
an  an 1  d , n  1
where a0 is the initial value. Find an explicit formula for an .

42
Solution:
Listing the first four terms of the sequence after a0 we find
a1  a0  d
a2  a0  2d
a3  a0  3d
a4  a0  4d
Hence, a guess is an  a0  nd . Next, we prove the validity of this
formula by induction.

Basis of induction: For n  0 a0  a0   0  d .


Induction hypothesis: Suppose that an  a0  nd .

Induction step: We must show that an1  a0   n  1 d . By the

definition of an 1 we have an1  an  d  a0  nd  d  a0   n  1 d .

Example 2.5
Consider the geometric sequence
an  ran1 , n  1
Where a0 is the initial value. Find an explicit formula for an .
Solution:
Listing the first four terms of the sequence after a0 we find
a1  ra0

a2  r 2 a0

a3  r 3a0

a4  r 4 a0

43
Hence, a guess is an  r n a0 . Next, we prove the validity of this
formula by induction.

Basis of induction: For n  0 , a0  r 0a0 .

Induction hypothesis: Suppose that an  r n a0 .

Induction step: We must show that an1  r n1a0 . By the definition of

an 1 we have an 1  ran  r  ra0   r n 1a0 .

Example 2.6
Find a solution to the recurrence relation
a0 0

an  an 1   n  1 , n  1
Solution:
Writing the first five terms of the sequence we find
a0  0
a1  0
a2  0 +1
a3  0 +1 + 2
a4  0 +1 + 2 + 3

A guessing formula is that


n  n  1
an  0  1  2     n  1 
2
We next show that the formula is valid by using induction on n  0 .

44
0  0  1
Basis of induction: a0  0   0.
2
n  n  1
Induction hypothesis: Suppose that an  .
2
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 2.7
Consider the recurrence relation
 a0 1

 an  2an1  n n  1

Is it true that an  2n  n is a solution to the given recurrence relation?


Solution:
If so then we must be able to prove its validity by mathematical
induction.
Basis of induction: a0  20  1 .

Induction hypothesis: Suppose that an  2n  n .

Induction step: We must show that an 1  2n 1   n  1 . If this is so

then we will have 2n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.

45
Example 2.8
Define a sequence, a1 , a2 ,... , recursively as follows:
a1 1
an  2  a n  , n  2
2

a. Use iteration to guess an explicit formula for this sequence.


b. Use induction to prove the validity of the formula found in a.
Solution.
Computing the first few terms of the sequence we find
a1  1
a2  2
a3  2
a4  4
a5  4
a6  4
a7  4
a8    a15  8

Hence, for 2i  n  2i 1 , an  2i . Moreover, i  log 2 n  i  1 so that

i  log 2 n  and a formula for an is

an  2 
log 2 n 
,n 1
b. We prove the above formula by mathematical induction.
Basis of induction: For n  1 , a1  1  2 log2 1 .

Induction hypothesis: Suppose that an  2 log2 n  .

Induction step: We must show that an1  2 log2 n 1 .

46
Indeed, for n odd (i.e. n  1 even) we have:
an 1  2  a n1 
 2 

 log 2 n21  log 2  n1 1 1 log 2  n1  11


 2  an 1  2  2  2  2
2

log 2  n1 
 2
A similar argument holds when n is even.

NOTATION:
We write a  n   an , or y  n   yn , n  

Example 2.9
Let n be the number of memory locations referenced by a certain computer
program. Suppose that the algorithm implemented by the program requires
yn bytes of the memory, where yn depends on n . Let yn be defined

inductively by
 y1  3

 yn  4 yn 1 if n  1

By this inductive definition, we generate the following table of Fibonacci


sequence:

n 1 2 3 4 5 …
yn 3 12 48 192 768 …

47
Sometimes it is more convenient to start at n  0 instead of n  1 . In fact, any
integer could be used as the starting value in the inductive definition or
recursive relation.

Example 2.10
The factorial function n! is defined as follows:
0!  1

n !  n  n  1 ! if n  1

It is desirable to find an explicit expression of yn as a function of n . To find


such an expression is called the solution process of the inductive definition
or recurrence relation.
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 .

Example 2.11
A function yn is defined recursively as follows:

 y1  3

 y2  7
 y  3 y  2 y for n  3
 n n 1 n 2

We want to find an explicit formula or solution for yn in terms of n . We


display some few initial terms of the Fibonacci sequence:

n 1 2 3 4 5 6 …
yn 3 7 15 31 63 127 …

48
By intuition, yn  2 n1  1. This formula clearly satisfies the initial
conditions y1 and y2 . We verify if it satisfies the recurrence relation
yn  3 yn 1  2 yn 2
But
R.H .S  3 yn1  2 yn 2
 3  2n  1  2  2n 1  1
 3  2n  3  2 n  2
 2n  3  1  1
 2n1  1
 yn
 L.H .S

When iteration does not apply, other methods are available for finding
explicit formulas for special classes of recursively defined.

CLASSIFICATION OF RECURRENCE RELATIONS


A recurrence relation is of first order if yn is defined only in terms of yn1 . It
is of second order if yn is defined in terms of yn1 and yn 2 , and so on.

A recurrence relation of the form yn  a1 yn 1  a2 yn 2  ...  ak yn  k is called a


linear homogenous recurrence relation of order k . Assuming that the ai are
constants, then the above equation is said to have constant coefficients.

Linear recurrence relations have the following important properties:


 multiplying any solution by a constant gives another solution,
 adding two or more solutions give another solution.
49
FIRST-ORDER RECURRENCE RELATIONS
First-order recurrence relations are of the form:
 yn  ayn1

 y0  c
We assume a and c are constants. We solve first-order recurrence relations
by iteration; a process of repetitive procedure, as displayed:
yn  ayn 1
 a  ayn 2 
 a 2  ayn3 
 ............
 a n 1 y1
 a n y0
Using the initial condition, we have yn  ca n , n    . By this procedure,
example 2.11 above, with a  4 and c  3  y1 , we have yn  a n 1 y1  3  4 n 1 .

As an exercise, show that this solution satisfies the recursive definition of


example 2, and generate the Fibonacci sequence as shown in example 2.

THE SECOND-ORDER RECURRENCE RELATION


Second-order recurrence relation has the form:
 yn  ayn 1  byn  2 for n  2

 y1  c1
y  c
 0 0
We assume a, b, c0 and c1 are constants, and also a trial function yn  ct n to
solve the relation above. By this assumption, yn1  ct n 1 and yn  2  ct n  2 .

50
Substituting these into the recurrence relation yn  ayn1  byn 2 , gives
ct n  act n 1  bct n  2 .

Dividing through by ct n  2 , we have t 2  at  b OR t 2  at  b  0 , which is


called the auxiliary or characteristic equation of the recurrence relation.
The auxiliary or characteristic equation is a quadratic equation and to solve
this, we have three possibilities
I. two distinct real roots t  t1 and t  t2
II. repeated real root t  t0  twice 

III. two complex roots t  t1 and t2  t1

CASE I
Since yn  t1n and yn  t2n are solutions of the linear recurrence relation, then
another solution (the general solution) is yn  At1n  Bt 2n . Where A and B are
arbitrary constants.
Using the initial values y0  c0 and y1  c1 , A and B are easily determined.

CASE II
As t  t0 is the repeated root of the characteristic equation, then yn  t0n is a
solution of the recurrence relation. The other linearly independent solution is
yn  nt 0n . So a general solution of the linear recurrence relation is

yn  At 0n  Bnt0n , where A and B are arbitrary constants.


Once again, using the initial values y0  c0 and y1  c1 , we can solve for
A and B .

51
CASE III
Since the characteristic equation has real coefficients, the complex roots
occur in conjugate pairs. In other words, if u  iv is a root of the
characteristic equation with real coefficients, then its complex conjugate
u  iv is also a root with v  0 .

By the general rule, the solution


yn  At1n  Bt2n
 A  u  iv   B  u  iv 
n n

Converting u  iv and u  iv into polar coordinates,


u  iv    cos   i sin  
u  iv    cos   i sin  

And by DeMoivre’s Theorem,


   cos   i sin      n  cos n  i sin n 
n

Then
yn  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

If we substitute A  B  12 , then yn   n cos n is a particular solution.


Similarly if we substitute A   12 i and B  12 i , then yn   n sin n is also a
particular solution. Therefore the general solution is
yn  A  n sin n  B  n cos n .

Where   u 2  v 2 and   tan 1 uv .

52
EXAMPLE 5
Solve
 yn  3 yn 1  2 yn 2 for n  2

 y2  7
y  3
 1

SOLUTION
The characteristic equation is t 2  3t  2  0 . Factorizing the left-hand side
gives
 t  1 t  2   0 so that t  1 or t  2 . The general solution is yn  A 1n  B  2n .

Using the initial conditions specified, A  1 and B  2 , therefore the solution


is
y n  1  2  2 n
 2n 1  1

EXAMPLE 6
Solve
 yn  6 yn1  9 yn 2 for n  1

 y1  3
y  5
 0

SOLUTION
The characteristic equation is t 2  6t  9  0 . Factorizing the left-hand side
gives  t  3  0 so that t  3  repeated  . The general solution is yn  A  3n  Bn  3n
2

.
Using the initial condition specified, A  5 and B  4 , therefore the solution is

53
yn  5  3n  4n  3n
 3n  5  4n 

EXAMPLE 7
Solve yn  2 yn 1  2 yn 2  0

SOLUTION
The characteristic equation is t 2  2t  2  0 . Using the quadratic formula, we
2  4  8
have the roots: t   1  i. Thus t1  1  i and t2  1  i .
2
Using the diagram,

1  i

3
4

1  i

 2  sin  2
n n
  2 and   34 . Hence, yn  A 3 n
4 B cos 3n4 is the general

solution.

We note that a characteristic equation is equally used for higher-order


recurrence relations. Sometimes a recurrence relation can be converted into
54
linear, constant-coefficient form although it might not originally be in that
form.

EXAMPLE 8
Solve
 yn  7 yn  2  6 yn  3

 y0  1, y1  2 and y2  3

SOLUTION
The characteristic equation is t 3  7t  6  0 . Factorizing the right-hand side
gives
 t  1 t  2  t  3  0 so that t  1, 2 and  3.

The general solution is yn  A 1n  B  2 n  C  3 .


n

5 4 11
Using the initial conditions, A  , B   and C  .
4 5 20

So the solution is yn     2n     3 .


5 4 11 n

4 5  20 

EXAMPLE 9
Consider the recurrence relation:
 yn   yn 1  6 yn  2

 y1  1
y  9
 0

SOLUTION
Using the substitution g n  yn transforms the recurrence relation into

55
 g n   g n1  6 g n 2

 g1  1
g  3
 0

Using the appropriate standard method


2
g n  1  3  2  2n and therefore yn  g n2  1 3  2  2n 
n n

 

Solve the following difference equations:


a  yn 1  ayn  0, y0  1
b yn  3 yn 1
c y n  2  2 yn  0
d yn  2 yn 1  2 yn 2  0
e yn  4 yn 1  8 yn 2  0; y0  2, y1  1
f  yn  4 yn 1  8 yn  2  0, y2  1, y3  2
g yn  2  2 yn1  4 yn  0

56
NON-HOMOGENEOUS DIFFERENCE EQUATIONS
So far we have considered difference equations of the form
ak yn  k  ak 1 yn k 1  ...  a0 yn    n  1
Where   n   0 for all n   . For now, we consider cases where   n  is a
non-zero function. In the case of a homogenous difference equations, that is,
where   n   0 , the general solution of (1) is obtained by adding any
particular solution of (1) to the general solution of the corresponding
homogenous equation.

THEOREM
Let   n  be a particular solution to
ak yn  k  ak 1 yn k 1  ...  a0 yn    n   2
and
1 g1  n    2 g 2  n   ...   k g k  n 

Be the general solution to ak yn  k  ak 1 yn  k 1  ...  a0 yn  0 .

Then
y(n)  1 g1  n    2 g 2  n   ...   k g k  n     n   3
is the general solution to (2).

EXAMPLE 1
Use the theorem above to find the general solution to
yn 2  5 yn 1  6 yn  2n  2  4

57
SOLUTION
We observe that   n   n2n1 is a particular solution of (4) for if

  n   n2n 1 then   n+1    n  1 2n  2 and   n  2     n  2  2n 3


and therefore
  n+2   5  n  1  6   n     n  2  2n 3  5  n  1 2n  2  6n2n 1
 2n 1  22  n  2   10  n  1  6n 
 2n 1  2  2n  2
As to how to have   n   n2n1 , will be studied later. We find the general
solution of the associated homogenous equation
yn  2  5 yn1  6 yn  0  5
The characteristic equation of (5) is: t 2  5t  6  0
With solution: t  2, 3 . Thus, the general solution to (5) is 1 2 n   2 3n , and by
the Theorem, the general solution of the non-homogenous equation (4)
yn  1 2n   2 3n  n 2 n 1 .

As an emphasis, we need to find only one particular solution of the non-


homogenous equation (as well as the general solution to the associated
homogenous equation), in order to completely solve the non-homogenous
equation. The theorem is useful when   n  in (1) is the sum of various
terms.

58
THEOREM:
If
F1  n  is a solution of
yn k  an  k 1 yn  k 1  ...  an yn  1  n   6
and
F2  n  is a solution of
yn k  an  k 1 yn  k 1  ...  an yn  2  n  7
then F1  n   F2  n  is a solution of
yn k  an  k 1 yn  k 1  ...  an yn  1  n   2  n 

Example
Find the general solution of
 
yn  2  3 yn 1  2 yn  4 2n  n  2 8 

Solution
The characteristic equation of the associated homogenous equation is
t 2  3t  2   t  2  t  1  0 .

Since the roots of this equation are t  1, 2 , the general solution of the
homogenous equation is 1   2 2n .
Direct substitution shows that y1  n   n2n1 is a solution of the non-
homogenous difference equation
 
yn  2  3 yn 1  2 yn  4 2n 9
And that F2  n    12 n2  52 n is a solution of the non-homogenous difference
equation
yn  2  3 yn 1  2 yn  n  2 10 

59
Thence from the theorem, F1  n   F2  n   n2n1  12 n2  25 n is a particular solution
to (8). Adding this particular solution to the general solution of the
homogenous equation gives yn  1   2 2n  n 2n 1  12 n 2  25 n as the general
solution of the non-homogenous difference equation (8).

In the problems below, show that   n  is a particular solution of the given


difference equation, and find the general solution to the difference equation.
If initial conditions are given, find also the particular solution that satisfies
those conditions.
1 yn 2  3 yn 1  2 yn  1;   n    n
1
 2 yn  2  2 yn 1  yn  5  3n;   n   n 2  n3
2

 3 yn 2  3 yn1  2 yn  3n ;   n     3n , y0  1, y1  0
1
2
 4  yn 2  4 yn1  4 yn  2 ;   n   n  n  1 2n3
n

1
 5 yn 2  4 yn  2n ;   n   n 2n , y1  3, y2  1
8
n2 4 11
 6  yn 2  4 yn  n2  1;   n     n 
3 9 27

 7  yn  10 yn1  25 yn2  2n ;   n     2n2


1
9
8 yn  4 yn1  4 yn2  2 ;   n   n2n3
n

9 yn  3 yn 1  2 yn 2  2n ;   n   n 21


2

10  yn  2  5 yn 1  6 yn  n;   n    n  
1 9
14  14 

60
n
11 yn 2  yn  n  1;   n   , y0  1, y1  0
2
12  yn 2  yn1  3 yn  2n  1;   n   2n  3
13 yn1  yn  1;   n   n, y1  1
14  yn1  3 yn  2;   n   3n  1
 2 
15  yn 2  5 yn1  6 yn  4n1;  n     4n
 21 
 3n  2 
16  yn  2 yn1  yn2  3 ;  n 
n 2

16

61
THE METHOD OF UNDETERMINED COEFFICIENTS

The method of undetermined coefficients is introduced with an example. We


consider the difference equation:
yn 2  2 yn 1  yn  6n 2  24n  25 1
Clearly the sum yn  2  2 yn1  yn will be equal to the polynomial 6n 2  24n  25
if and only if y is a second-degree polynomial. For a solution of (1), we
consider
yn  y  n   A2 n 2  A1n  A0 , where A2 , A1 and A0 are constants to be determined.

This is reasonably possible by substituting yn  A2 n 2  A1n  A0 into (1).

We however observe that if yn  A2 n 2  A1n  A0 , then

yn 1  y  n  1  A2  n  1  A1  n  1  A0
2

 A2 n 2   2 A2  A1  n   A2  A1  A0 
yn  2  A2  n  2   A1  n  2   A0
2

 A2 n 2   4 A2  A1  n   4 A2  2 A1  A0 
Consequently
yn  2  2 yn 1  yn  A2 n 2   4 A2  A1  n   4 A2  2 A1  A0 
 2 A2 n 2  2  2 A2  A1  n  2  A2  A1  A0 
 A2 n 2  A1n  A0
 2 A2 n 2   8 A2  2 A1  n   6 A2  4 A1  2 A0 

Thus for yn  A2 n 2  A1n  A0 to be a solution to (1), then

2 A2 n 2   8 A2  2 A1  n   6 A2  4 A1  2 A0   6n 2  24n  25 .

62
This equation is valid for all n if and only if the corresponding coefficients
are equal. Thus
2 A2  6
8 A2  2 A1  24
6 A2  4 A1  2 A0  25

From these,
7
A2  3 , A1  0 , A0 
2
7
Substituting these values into yn  A2 n 2 A1n  A0 , we have   n   3n 2  as
2
a particular solution to the non-homogenous equation (1).
To apply the method successfully, it is necessary to have the correct form for
a trial solution. The following table gives the correct form of a trial solution
to a difference equation: yn  k  an  k 1 yn k 1  ...  an yn    n 

For various functions   n  .

 n Form of trial solution

am n m  am1n m1  ...  a1n  a0 Am n m  Am 1n m1  ...  A1n  A0



k n am n m  am 1n m 1  ...  a1n  a0  
k n Am n m  Am 1n m 1  ...  A1n  A0 

Example 1
Find the general solution of
 
yn  3 yn 1  10 yn  2  3 2 n  2

63
Solution:
The characteristic equation of the homogenous equation is
t 2  3t  10  0 OR  t  5  t  2   0  t  5,  2 .
Therefore the general solution of the homogenous equation is:
1 5n   2  2  , since   n   3  2 n  is of the form ck n . By the table above,
n

c  3 and k  2 , we select a trial solution of (2) in the form yn  c 2 n .


Substituting this into (2), we have
c 2 n  3c 2 n 1  10c 2 n  2  3  2 n   3

Dividing through this by 2n2 , we have


c 22  3c 2  10c  3  22  or  12c  12
so that c  1
Therefore yn  2 n is a particular solution of (2).

Consequently by the above theorem, yn  1 5n   2  2   2 n is a general


n

solution of (2).

Example 2
Find the general solution of
yn  2  yn 1  6 yn  6n 2  22n  23  4

Solution:
The characteristic solution of the associated homogenous equation is
t 2  t  6  0 or  t  3 t  2   0 then t  3,  2 .

64
Therefore the general solution of the homogenous equation is
1  2    2 3n , since   n   6n 2  22n  23 is of the form a1n 2  a1n  a0 .
n

By the table, we select the trial solution: yn  A2 n 2  A1n  A0 .


Substituting yn  A2 n 2  A1n  A0 into (4) yields

 A2  n  2 2  A1  n  2   A0    A2  n  12  A1  n  1  A0   6  A2 n 2  A1n  A0 
   

This reduces to 6 A2 n2   2 A2  6 A1  n   3 A2  A1  6 A0   6n2  22n  23 .

In order for this equation to be valid for all n , the corresponding coefficients
must be equal hence,
6 A2  6, 2 A2  6 A1  22, 3 A2  A1  6 A0  23.
From these, A2  1, A1  4 and A0  5 so that
  n    n 2  4n  5
is a particular solution to the non-homogenous equation (4).

The general solution, therefore, is yn  1  2    2 3n  n 2  4n  5


n

A slight complication arises in the use of the table whenever a term of the
selected trial solution is also a solution to the homogenous equation. If this
occurs, we multiply every term of the trial solution by n . If this new trial
solution still has a term that is a solution to the homogenous equation, we
again multiply the trial solution by n . This process continues until no term
of the trial solution is a solution of the homogenous equation.

For example, if   n   n2  1 , then the trial solution would ordinarily be of the

form A2 n 2  A1n  A0 . Say, however, that the general solution of the

65
homogenous equation is 1n   2 . Then both A1n and A0 are solutions of the
homogenous equation. Multiplying the original trial solution by n gives
A2 n 3  A1n 2  A0 n as a trial solution. However, since A0 n is still a solution to

the homogenous equation, we again multiply by n to obtain A2 n 4  A1n3  A0 n 2


.

Since none of the terms A2 n 4 , A1n3 or A0 n 2 of the proposed solution is a


solution to the homogenous equation, A2 n 4  A1n3  A0 n 2 is the desired trial
solution.

Example 3
Find the general solution of
yn  4 yn 1  4 yn 2  2n  5

SOLUTION
The characteristic equation of the associated homogenous equation is
t 2  4t  4  0 or  t  2   0, then t  2  repeated .
2

Therefore the general solution of the homogenous equation is 1 2 n   2 n 2 2 .


But   n   2n so we are prompted to select our trial solution as c 2n , where c
is a constant.

However c 2n and cn 2n are both solutions to the homogenous equation and,


therefore, we multiply 2n by n 2 to use cn 2 2n as the form of the trial solution.
Substituting yn  cn 2 2n into the non-homogenous equation, we have
cn 2 2 n  4cn 2 2 n 1  8cn 2 n 1  4c 2 n 1  4cn 2 2 n  2  16cn 2 n  2  16c 2 n  2  2 n .

66
Dividing throughout by 2n2 , we obtain
4cn2  8cn2  16cn  8c  4cn2  16cn  16c  4 from which we have 8c  4 or c  12 .
Consequently,   n   12 n 2 2n  n 2 2n 1 is a particular solution to the non-homogenous
equation (5) and therefore the general solution of (5) is yn  1 2n   2 n22  n 2 2n 1.

Example 4
Find the general solution of
yn  2  w2 yn  2n ; y0   , y1    6

Solution
The characteristic equation is t 2  w2  0 or t   iw .
The general solution of the associated homogenous equation is

1  iw    2  iw   wn 1i n   2  i  
n n n

 wn 1e   2e   since  i  e 
n i n i i
2 2 2

 wn 1 cos n2  i sin n2    2 cos n2  i sin n2 
 wn  A cos n2  B sin n2 

To find a particular integral, our trial solution is   n   c 2n . Substituting this


into the non-homogenous equation, we have
1
c 2n  2  w2c 2n  2n so that c  4  w2   1 or c  .
4  w2

The general solution of the non-homogenous equation is


2n
yn   wn  A cos n2  B sin n2  7
4w 2

67
Finally we use the initial conditions y0   and y1   to find the values of A and B
in (6).
1 2
y0   A   , y1   wB   so that
4w 2
4  w2
1  2
A   B 
4w 2
w w  4  w2 

Therefore the solution is

2n 
n  1   2  n 
yn   w     2 
cos n
    sin 2 
4  w2   4  w 
2

 w w  4  w 
2 
 
Finally, we give an example of an important use of difference equations.
Most especially, we use difference equations to evaluate certain sums.

Example 5
n
If sn  s  n    k 2 , find a simple expression for the summation.
k 1

Solution:
We write
sn  sn 1  n 2 8
This is a non-homogenous equation. We find its general solution. The
associated homogenous equation is sn  sn1  0 , whose general solution is  ,
since sn  sn 1  sn 2  ...  s0   , a constant. Since,   n   n2 , we have a trial

solution of the form A2 n 2  A1n  A0 .

68
However since A0 is a constant and is also a solution of the homogenous
equation, we multiply this trial solution through by n . The resulting trial
solution is A2 n 3  A1n 2  A0 n .
Substituting this into (8), we have A2n3 + A1n2 + A0n – A2(n-1)2 – A0(n-1) =
n2. Simplifying this, we select A2, A1 and A0; 3A2n2 + (2A1 – 3A2)n + (A0 – A1
+ A2) = n2 for all integers n , from which it follows that
3 A2  1, 2 A1  3 A2  0 and A0  A1  A2  0.
1 1 1
Therefore A2  , A1  and A0  , so
3 2 6
1 1 1
  n   n3  n 2  n is a particular solution of (8).
3 2 6
Adding this to the general solution of
the homogenous solution,
1 1 1 1 1 1
sn  n3  n 2  n   . Since s1  1, we have 1      ,
3 2 6 3 2 6
n
1 1 1
which gives   0, so sn   k 2  n3  n 2  n 9
k 1 3 2 6

69
a. In the following problems, find the general solution if the initial
conditions are given, find the particular solution that satisfies those
conditions.
1 y  y  2 y  3
n2 n 1 n
n

 2 y  2 y  8 y  5
n n 1 n 2
n2

 3 y  4 y  3 y  4
n n 1 n2

 4  y  y  2 y  2 ; y  2, y  1
n 2 n 1 n
n
0 1

 5 y  2 y  y  4; y  2, y  1
n2 n 1 n 1 2

 6  y  3 y  10 y  36n  21
n2 n 1 n

 7  y  9 y  n  4n  1
n n2
2

 8 y  9 y  n  5n  3
n 2 n
2 n

 9  y  2 y  8 y  5n  14; y  0, y
n2 n 1 n 0 1
 1
10  2 y  3 y  5 y  5  4
n 1 n n 1
n 1

11 y  4 y  6n  32n  23  2


n n2
2 n 1

12  y  6 y  12 y  8 y  3
n n 1 n2 n 3
n

b. In the following problems, use the techniques of example 5 of this


section to find simple expression for the given sum.
n
13  k
k 1
n
14   r k
k 1
n
15   1
k
k
k 1

70
n
16  2
k 1
k

n
17   2k k
k 1
n
18   1
k
k2
k 1

(19) Use induction to show that for each positive integer n


n
1 1 1
k
k 1
2
 n3  n2  n .
3 2 6

71
Unit4

BOOLEAN ALGEBRA AND BOOLEAN FUNCTIONS

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.

BASIC DEFINITIONS AND THEOREMS

DEFINITION (BOOLEAN ALGEBRA)


Let B be a set with 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 ;

B1 : commutative laws:

ab ba
a b  b  a
B2 : Distributive laws:

a  b  c    a  b    a  c 
a  b  c    a  b    a  c 

B3 : Identity Laws

72
a0 a
a 1  a
B4 : Complement Laws
a  a  1
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. 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  '

THE BOOLEAN ALGEBRA B WITH TWO ELEMENTS 0 AND 1


(CALLED BITS)
Let  and  be the binary operations in B . Let 0'  1 and 1'  0 .

 '
1 0
0 1

73
Then we have the following two fundamental tables:

+ 1 0
1 1 1
0 1 0

* 1 0
1 1 0
0 0 0

Example 1
Find the value of 1 0   0  1 '
Solution:
From the tables:
 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).

74
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 : B n   x1 , x2 ,..., xn  xi  B, 1  i  n  B is called a

Boolean function of degree n . The values of a Boolean function are


displayed in tables.

Example 2
The Boolean function F  x, y  with the value 1 when x  1 and y  0 and the

value 0 for all other choice of x and y is represented by the table

x y F  x, y 

1 1 0
1 0 1
0 1 0
0 0 0

Boolean functions are represented by Boolean expressions made up of the


variables and the Boolean operations. Boolean algebra  B, , , ', 0, 1 are
defined recursively as
For each s  B , s is a Boolean expression. x1 , x2 ,..., xn are Boolean

expressions.
If x1 and x2 are Boolean expressions, so are x1' , x2' , x1  x2 and x1  x2 .

75
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.

Example 3
Find the values of the Boolean function represented by F  x, y, z   xy  z '

Solution:

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

The Boolean functions F and G of n variables are equal if and only if


F  b1 , b2 ,..., bn   G  b1 , b2 ,..., bn  whenever b1 , b2 ,..., bn  B .

Two different expressions that represent the same function are called
equivalent. For example, the Boolean expressions: xy , xy  0, xy 1 are
equivalent.

76
The complement of the Boolean function F is the function F ' .

Let F and G be Boolean functions of degree n . The Boolean sum F  G and


the Boolean product F  G are defined by
 F  G  x1 , x2 ,..., xn   F  x1 , x2 ,..., xn   G  x1 , x2 ,..., xn 
 F  G  x1 , x2 ,..., xn   F  x1 , x2 ,..., xn   G  x1 , x2 ,..., xn 
Recalling the definition of a function or a given domain into a co-domain
using exponentiation, we have b  f : f : B  A  b  A    . Where b denotes
b B

the cardinality or distinct number of elements in a given set.

Therefore a Boolean function of degree 2, by definition, is a function from a


set with four elements, namely, pairs of elements from B  0,1 , to B , a set
of two elements. Hence, there are 2 4  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  .

In a similar analysis, the different Boolean functions of degree n is 22 n .

77
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 IDENTITES

Identity Name
 x ' '  x Law of double complement

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  yx
Commutative laws
xy  yx

x   y  z   x  y  z
Associative laws
x  yz    xy  z

x   yz    x  y  ( x  z )
x  y  z   xy  xz Distributive laws

 xy  '  x ' y ' De Morgan’s laws


 x  y  '  x ' y '

78
Example 4
Show that the distributive law x  y  z   xy  xz is valid.

Solution:
The verification is shown in the following table

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.

Example 5
Prove the absorption law x  x  y   x , verify the identities of Boolean
algebra.

79
Solution:
The steps used to derive this identity and the law used in each step follows:
x  x  y    x  0  x  y  Identity law for the Boolean sum
 x  0  y Distributive law of the Boolean sum over the Boolean product
 x  y 0 Commutative law for the Boolean product
 x0 Dominance law for the Boolean product
x Identity law for Boolean sum

DULITY
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
Find the duals of x  y  0  and x '1   y ' z  .
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.

The dual of a Boolean function F represented by a Boolean expression is


the function represented by the dual of this expression. This dual function,
denoted by F d , does not depend on the particular Boolean expression used
to represent F .

80
An identity between functions represented by Boolean expressions remains
valid when the duals of both sides of the identity are taken. That is, if F and
G are Boolean functions represented by Boolean expressions in n variables
and F = G, then Fd = Gd, where Fd and Gd are the Boolean functions
represented by the duals of the Boolean expressions representing F and G,
respectively. This result, called the duality principle is useful for obtaining
new identities.

Example 7
Construct an identity from the absorption law: x  x  y   x given in example
5 by taking duals.

Solution:
Taking duals of both sides of this identity produces the identity x   xy   x ,
which is also called an absorption law.

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]
4. How many different Boolean functions are there of degree 7?

81
5. Prove the absorption law x  xy  x using the laws in table 5.
6. Show that F  x, y, z   xy  xz  yz has the value 1 if and only if at least

two of the variables x, y and z have 1. (use tables)


7. Show that xy ' yz ' x ' z  x ' y  y ' z  xz ' . (use tables)

Exercise 8-15 deal with the Boolean algebra defined by the Boolean sum
and Boolean product on 0,1
8. Verify the law of double complement
9. Verify the idempotent laws
10.Verify the identity laws
11.Verify the dominance laws
12.Verify the commutative laws
13.Verify the associative laws
14.Verify the first-distributive law in Table 5
15.Verify De Morgan’s laws.

The operator  , called the xOR operator, is defined by


a  1  1  0, 1 0  1 1 0  1 and 00  0

16.Simplify the following expressions


a  x0 b x 1 c xx d x x'

(use tables)
17.Show that the following identities hold:
a  x  y   x  y  xy  '  b x  y   xy '   x ' y 

18.Show that x  y  y  x

82
19.Prove or disprove the following equalities
a  x   y  z   x  y  z
b x   y  z   x  y   x  z
c x   y  z   x  y   x  z

83
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.

The foregoing problems have practical importance in circuit design.

SUM OF PRODUCTS EXPANSIONS


We use examples to illustrate one important way to find a Boolean
expression that represents a Boolean function.

Example 1
Find Boolean expressions that represent the functions F  x, y, z  and G  x, y, z  ,
which are given in Table 1.

84
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
F has value 1 when x  z  1 and y  0 and  otherwise. Such an expression is

formed by taking the Boolean product of x, y ' and z . This product xy ' z has
value 1 if and only if x  y '  z  1 , which holds if and only if
x  z  1 and y  0 .

To represent G , we need an expression that equals 1 when x  y  1 and z  0 ,


or when 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 G, since it has the value 1 if
and only if x  y  1 and z  0 or x  z  0 and y  1 .

85
DEFINITION
A literal is a Boolean variable or its complement. A minterm of the
Boolean variables x1 , x2 ,..., xn is a Boolean product y1 , y2 ,..., yn where
yi  xi or yi  xi' . Hence, a minterm is a product of n literals with one literal

for each variable.

Example 2
Find a minterm that equals 1 if x1  x3  0 and x2  x4  x5  1 , and equals 0
otherwise.

Solution
The minterm x1' x2 x3' x4 x5 has the correct set of values.

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.

86
Example 3
Find the sum of products expansion for the function F  x, y, z    x  y  z

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.
This gives F  x, y, z   xyz ' xy ' z ' x ' yz ' .
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

It is also possible to find a Boolean expression that represents a Boolean


function by taking a Boolean product of Boolean sums. The resulting
expansion is called the 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.

87
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 therefore say that the set , , ' is functionally
complete.

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.

There are two such procedures, in a De Morgan’s laws:


I. Eliminate all Boolean sums using the identity
x  y   x ' y ' '

Thus the set , ' is functionally complete.


II. Eliminate all Boolean products using the identity
xy   x ' y ' '

Thus the set , ' is functionally complete.

However, the set , + is not functionally complete.


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

88
 1 0
1 0 0
0 0 1

Define two operator  or NAND (not AND) operator, defined by


11  0 and 1 0  0 1  0 0  0; and  or NOR  not OR 

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 

Exercise
1. Find a Boolean product of the Boolean variable x, y and z or their
complements, that has the value 1 if and only if
 a  x  y  0, z  1
 b  x  0, y  1 z  0
 c  x  0, y  z  1
d  x  y  z  0

2. Find the sum-of-products expansions of the following Boolean


functions

89
 a  F  x, y   x ' y
 b  F  x, y   xy '
 c  F  x, y   1
 d  F  x, y   y '

3. Find the sum-of-products expansions of the following Boolean


functions
 a  F  x, y, z   x  y  z
 b  F  x, y , z    x  z  y
 c  F  x, y , z   x
 d  F  x, y, z   xy '

4. Find the sum-of-products expansions of the Boolean function


F  x, y, z  that equals 1 if and only if

a x0 b xy  0


c x y 0 d  xyz  0

5. Find the sum-of-products of the Boolean function F  w, x, y, z  that has

the value 1 if and only if are odd number of w, x, y and z have the value
1

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 have the value 1.

90
In question numbers 7-11, find a Boolean expression that represents a
Boolean function formed from a Boolean product of Boolean sums of
literals.

7. Find a Boolean sum containing either x or x ' , either


y or y 'and either z or z ' that have the value 0 if and only if

a x  y  1, z  0
b  x y z0
c x  z  0, y  1

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 Boolean sum is called a maxterm.

10.Show that a Boolean function can be represented as a Boolean product


of maxterms. This representation is called the product-of-sums
expansion or conjugate normal form of the function. (Hint: include
one maxterm in this product for each confirmation of the variables
where the function has the value 0).

11.Find the product-of-sums expansion of each of the Boolean functions


in (3).

91
12.Express each of the following Boolean functions using the operators
 and ' .

a x  y  z
 b  x  y '  x ' z 
 c   x  y ' '
 d  x '  x  y ' z '
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  y   x x  y y 

15.Show that
a x'  x  x b xy   x  x    y  y 

c x  y  x  y   x  y

16.Show that  is functionally complete using (15)

17.Express each of the Boolean functions in (3) using the operator .

18.Express each of the Boolean functions in (3) using the operator  .

92
LOGIC GATES

We use Boolean algebra to model the circuiting of electronic devices. We


take each input and each output of such a device as a member of the set 0,1
.
A computer, or any electronic device, is made up of circuits. Each circuit is
designed using the rules of Boolean algebra so far studied. The basic
elements of circuits are called gates, so that each type of gate implements a
Boolean operation. With these gates, we apply the rules of Boolean algebra
to design circuits to perform variety of tasks. Such circuits give output, that
depends only on the inputs, and not on memory capacities. Such circuits are
called combinatorial circuits.

Combinatorial circuits are constructed using three basic types of elements


which we describe as follows:
I. An inverter: This accepts the value of a Boolean variable as an input
and produces its complement as its output. This is represented by

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

93
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
Output
y
Input

More inputs are permitted to AND and OR gates. Such situations are shown
below
x1
x2
x1 x2 ...xn
...
xn

x1
x
x1  x2  ...  xn
2

...
x n

94
2-4.1 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.

95
x xy

y
xy  x ' y

x'
x x' y

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 1
Construct circuits that produce the following outputs:
 a   x  y  x '; b x '  y  z '  ';
 c   x  y  z  x ' y ' z '

96
SOLUTION

(a)

x x y

y
 x  y x '

x'
x

OR

x x y

y
 x  y x '

x'

97
(b)

x'
x
x '  y  z ' '

y  y  z '  x  z ' '


z'
z

x
 x  y  z
y

 x  y  z  x ' y ' z '


x'
x
y' x' y'z'
y

z'
z

EXAMPLES OF CIRCUIT
We give some examples of circuits that perform some useful functions.

Example 2
A committee of three individuals decides issues for an organization. Each
individual votes either yes or no for each proposal that arises. A proposal is

98
passed if it received at least two yes votes. Design a circuit that determines
whether a proposal passes.

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 .

We draw the circuit of F  x, y, z  .

x xy

x xz
xy  xz  yz
z

y yz

Draw the circuit of F  x, y, z   xy  xz  xyz  yz .

99
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:
I. For two switches
Let x  1 when the switch is closed and x  0 when it is opened and let y  1
when the 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. When one of the two switches is
opened, the light goes off, so F 1, 0   F  0,1  0 . When the other switch is

opened, the light goes on, so that F  0,0   1 . The following table displays
these values.

x y F  x, y 

1 1 1
1 0 0
0 1 0
0 0 1

100
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

II. For three switches


Let x, y and z be the Boolean variables that indicate whether each of the
three switches are closed.
Let x  1 when first switch is closed and x  0 when it is opened;
Let y  1 when the second switch is closed and y  0 when it is opened;
Let z  1 when the third switch is closed and z  0 when it is opened.
Let F  x, y, z   1 when light is on and F  x, y, z   0 when the light is off.
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 goes off, so that F 1,1, 0   F 1, 0,1  F  0,1,1  0 .
When a second switch is opened, the light goes on, so that
F 1, 0,0   F  0, 0,1  F  0,1, 0   1 . Finally, when the third switch is opened, the

light goes off again, so that F  0, 0, 0   0 . The following table and circuit
display the foregoing analysis.

101
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

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

Where F  xyz  xy ' z ' x ' yz ' x ' y ' z is the sum-of-products expansion.

102
In (1) to (5), find the output of the given circuit.

103
1 2
x
x

y
y

3 4
x x
y
y z

x
y
z
z

x
x
y
z 5

x
y
z
x
y

104
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.

105
Unit5

RELATIONS AND ORDER IN A SET

Introduction
There is the need to have a modicum knowledge of pure mathematics. This
unit does exactly that. It ushers you into an interesting area of mathematics.
This unit is a must-do
do unit.

Objectives
On completion of this unit, you would be able to:
 Identify some basic theories in pure mathematics
 Apply the knowledge gained to analytic courses in the
years ahead

RELATIONS IN A SET

DEFINITIONS
A binary relation (or relation)  from a set of A to a set B assigns to each
pair a, b in A  B exactly one
on of the following statements:

(i) " a is related to b " , written a b

(ii) " a is not related to b " , written a b .

A relation from a set A to the same set A is called a relation in A .

106
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

On the other hand, any subset  of A  B defines a relation  from A to B as:


ab iff a, b  

Domain of   a : a, b  

Range of   b : a, b  

EQUIVALENCE RELATIONS
DEFINITION
A relation  in a set A , that is, a subset  of A  A is called an equivalence
relation if and only if it satisfies the following axioms:
 E1  For every a  A, a, a  , reflexive property
 E 2  If a, b   , then b, a  , symmetric property
 E3  If a, b   , and b, c  , then a, c   , transition property
Accordingly, a relation  is an equivalence relation if and only if it is
reflexive, symmetric and transitive.
If  is an equivalence relation in A , then the equivalence class of any
element a  A , denoted by  a  , is the set of elements to which a is related.

a  x : a, x  

The collection of equivalence classes of A denoted by A /  , is called the


quotient of A by  . A /    a  : a  A

The quotient set A /  possesses the following properties:

107
THEOREM
Let  be an equivalence relation in A and let  a  be the equivalence class of
a  A . Then:

 i  For every a  A, a   a 
 ii   a   b  , iff a, b  
 iii  If  a   b  , then  a  and b  are disjoint
A class a of non-empty subsets of A is called a partition of A if and only if
1. each a  A belongs to some member of a and
2. the members of a are pairwise disjoint.
Therefore, the theorem above implies the following fundamental theorem of
equivalence relations.

THEOREM
Let  be an equivalence relation in A . Then the quotient set A /  is a
partition of A .

Example 1
Let  5 be the relation in  , the set of integers, defined by x  y  mod 5 ,

which reads “ x is congruent to y modulo 5” and which means “ x  y is


divisible by 5”. Then  5 is an equivalence relation in  . There are exactly
five distinct equivalence classes in  /  5 :
E0  ..., 10, 5, 0,5,10,...   0
E1  ..., 9, 4,1, 6,11,...  1
E2  ..., 8, 3, 2,7,12,...   2
E3  ..., 7, 2,3,8,13,...  3
E4  ..., 6, 1, 4,9,14   4

108
We observe for each integer x, x  5 p  r where 0  r  5 , is a member of the
equivalence class Er , where r is the remainder when x is divided by 5.
Note that the equivalence classes are pairwise disjoint and that
Z  E0  E1  E2  E3  E4

Example 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 < and > in the set A . Thus a, b  iff a  b, and a, b  1 iff a  b .

The identity relation in any set A , denoted by  or  A , is the set of pairs in


A  A with equal coordinates, that is,  A   a, a : a  A

1. Prove: let  be a relation in A , that is   A  A . Then


(i)  is reflexive if and only if  A  
(ii)  is symmetric if and only    1
2. Consider the relation    1,1 , 2,3 , 3, 2  in X  1, 2,3 . Determine

whether or not  is (i) reflexive, (ii) symmetric, (iii) transitive

109
3. Consider the set    , that is, the set of ordered pairs of positive
integers. Let  be the relation  in    which is defined by
a, b  c, d iff ad  bc .

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
(i) Prove  is an equivalence relation
(ii) Find the equivalence class of 2,5 that is  2,5 

110
ORDERING OF A SET
PARTIAL ORDERING
A relation  in a set A is called a partial order (or order) if and only if, for
every a, b, c  A such that
(i) a  a , reflexive property
(ii) a  b and b  a implies a  b , anti-symmetric property
(iii) a  b and b  a implies a  c , transitive property
The set A together with the partial order, that is, the pair  A,   is called a
partially ordered set. A partial order is a reflexive, anti-symmetric and
transitive relation.

Example 1
Set inclusion is a partial order in any class of sets since
 i  A  A is true for any set A
 ii  A  B and B  A implies A  B for any sets A, B
 iii  A  B and B  C implies A  C for any sets , A, B and C

Example 2
Let A be any set of real numbers. Then the relation in A defined by x y is a
partial order and is called the natural order in A .

111
Example 3
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 direction that is upward.

b c

DEFINITION
If ab in an ordered set, we say, a precedes or is smaller than b and that b
follows or dominates or is larger than a . We write a  b if a  b but a  b .

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.

112
Example 4
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
If a relation  in a set A defines a partial order, that is, is reflexive, anti-
symmetric and transitive, then the inverse relation  1 is also a partial order,
it is called the inverse order.

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 ab as elements
in A if and only if ab as elements in X . More precisely, if  is a partial
order in X , then the relation
 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.

113
Example 5
Consider the partial order in W  a, b, c, d , e defined by the diagram

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 not totally ordered subsets.

FIRST AND LAST ELEMENTS

Let X be an ordered set. An element a0  X is a first or smallest element of


X if and only if a0 x for all x  X . Similarly, an element b0  X is a last or

largest element of X if and only if xb0 for all x  X .

114
Example 6
Let X  a, b, c, d , e be ordered by the diagram,

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 7
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.

MAXIMAL AND MINIMAL ELEMENTS


Let X be an ordered set. An element a0  X is maximal if and only if a0  x
implies x  a0 , that is, if no element follows a0 except itself. Similarly, an
element b0  X is minimal if and only if x b0 implies x  b0 , that is, if no
element precedes b0 except itself.

115
Example 8
Let X  a, b, c, d , e be ordered by the diagram of Example 6. Then both
d and e are minimal elements. The element a is a maximal element.

Example 9
Although  with the natural order is totally ordered it has no minimal and no
maximal elements.

Example 10
Let A  a1 , a2 ,..., am  be a finite totally ordered set. Then A contains precisely
one minimal element and precisely one maximal element, denoted
respectively by
min a1 ,..., am  and max a1 ,..., am 

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 element   X is an upper bound of A if

and only if x for all x  A , that is, if  follows every element in A . If some
upper bound of A precedes every other upper bound of A , then it is called
the least upper bound (L.U.B) or supremum of A and is denoted by sup  A .

116
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 11
Let X  a, b, c, d , e, f , g be ordered as shown in the following diagram:

a b

c
B

d e

g
f

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 . Furthermore, c  sup  B  belongs to B , while f  inf  B  does not
belong to B .

Example 12
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.

117
Example 13
Let  be the set of rational numbers. Let B   x : x  , x  0, 2  x 2  3 . Then

B has an 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
1. Let  , the positive integers, be ordered as follows: each pair of
elements a, a '   can be written uniquely in the form
a  2r  2s  1 , a '  a r '  as ' 1

Where r , r ', s, s '  0,1, 2,3,... . Let a  a ' if r  r or if ' r  r ' but s  s ' .
Insert the correct symbol,  or  , between each of the following pairs
of numbers. (Note: x  y iff y  x ).
(i) 5……14 (ii) 6…………9
(iii) 3……..20 (iv) 14………21
2. Let A  a, b, c be ordered as in the diagram below. Let  be the
collection of 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

118
3. Let A  2,3, 4,...   \ 1 and let A be ordered by " x divides y " .
(i) Determine the minimal elements of A
(ii) Determine the maximal elements of A .

4. Let B  2,3, 4,5, 6,8,9,10 be ordered by " x is a multiply of y " .


(i) Find all maximal elements of B
(ii) Find all minimal elements of B .

5. Let W  1, 2,...,7,8 be ordered as follows:

1 2

4 5

6 7

Consider V  4,5, 6 , a subset of W


(i) Find the set of upper bounds of V
(ii) Find the set of lower bounds of V
(iii) Does sup V  exist?

(iv) Does inf V  exist?

6. Let A   ,   , the positive integers with the natural order; and let

B   ,   , the positive integer with the inverse order. Furthermore, let

119
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 .

3 4

5 6

(i) Find the maximal elements of X


(ii) Find the minimal elements of X
(iii) Does X have a first element?
(iv) Does X have a last element?
(v) Find the set of upper bounds of A
(vi) Find the set of lower bounds
(vii) Does sup (A) exist?
(viii) Does inf (A) exist?

120
8. Consider  , the set of rational numbers, with the natural order, and its
subset A   x : x  , x 3  3

(i) Is A bounded above?


(ii) Is A bounded below?
(iii) Does sup  A exist?

(iv) Does inf  A exist?

9. Let  , the positive integers, be ordered by " x divides y " and let
A 
(i) Does inf  A exist?

(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.

121

You might also like