Académique Documents
Professionnel Documents
Culture Documents
1: Title
MATH1081
DISCRETE MATHEMATICS
Se tion 4
Comments.
Note that each of the above involves assumptions on any
connections between the first and second choices. Here
are some examples which violate these assumptions.
In semester 2 last year 172 students studied
MATH1081 and 1445 studied MATH1231. The
number of ways to choose a student who studied
either MATH1081 or MATH1231 is not 172 + 1445.
Why not?
The School of Mathematics offers 8 different first year
courses in first semester and 7 in second semester.
The number of ways in which a student can do one
course from each semester is not 8 7. Why not?
We will sometimes expect you to use common sense in
solving counting problems! For instance, in the problem
on page 3 we would expect you to realise that a main
course would not (usually?) be eaten for dessert (so there
is no overlap between the two parts of the menu).
MATH1081 Discrete Mathematics 4.5: Words
Note that for this course a word is any string of letters from
a given alphabet. It does not matter whether or not the word
is in the dictionary, or whether or not it makes sense. For
example, if we have an alphabet { A,C,T } consisting of just
three letters, some of the words we can form are
Solution.
(a) We set out the working step by step.
(b) Note that we must choose not only the letters, but also
where they go.
1. Choose a place for the vowel . . . . . 3 ways
2. Choose the vowel . . . . . . . . . . . . . . . . 5 ways
3. Choose the first consonant . . . . . . . 21 ways
4. Choose the second consonant . . . . 21 ways
The number of possible words is 3 5 212 .
(c) The number of words with exactly one vowel is 3 5 212 ,
as above. Next we count the words with two vowels,
1. Choose a place for the consonant . . . . 3 ways
2. Choose the consonant . . . . . . . . . . . . . . . 21 ways
3. Choose the first vowel . . . . . . . . . . . . . . . 5 ways
4. Choose the second vowel . . . . . . . . . . . . 5 ways
giving 3 21 52 words, and those with three vowels,
1. Choose the first vowel . . . . . . . 5 ways
2. Choose the second vowel . . . . 5 ways
3. Choose the third vowel . . . . . . 5 ways
giving a further 53 . A word contains at least one vowel
if it contains one or two or three, so the final answer
is obtained by adding these three partial totals. The
number of words is
3 5 212 + 3 21 52 + 53 .
Alternative solution. As in (a), the total number of words
with three letters is 263 . However we do not wish to
count the words with no vowels, and there are 213 of
these (why?). So the number of words with at least one
vowel is
263 213 .
MATH1081 Discrete Mathematics 4.7: Solution (d)
Comments.
For counting problems, always be sure to set out your
working clearly, listing the choices to be made and
the number of options in each case, then combine the
subtotals by means of addition and/or multiplication to
obtain the final answer.
The two alternative answers for part (c) may be surprising
as they do not appear to be the same! In fact they are
equal, as you can confirm with the aid of a calculator.
Exercise. Using basic algebra, confirm without using a
calculator that the two answers are the same.
Usually we would not solve a counting problem by going
all the way back to addition and multiplication; we
shall develop techniques by which substantial parts of
a problem can be solved in a single step. The above
problems illustrate two of these techniques.
MATH1081 Discrete Mathematics 4.9: Powers
Solutions.
MATH1081 Discrete Mathematics 4.14: Permutations
n(n 1) (n (r 1))(n r) 2 1
P (n, r) =
(n r) 2 1
n!
= .
(n r)!
The spades and clubs are coloured black, while the hearts and
diamonds are red.
A selection of cards from a pack is referred to as a hand of
cards. We shall assume (as is true in most card games) that a
hand may not contain the same card twice, and that the order
of cards in a hand is not important.
MATH1081 Discrete Mathematics 4.18: Combinations
P (13, 13) .
Is repetition allowed?
Is order important?
P (n, r) n!
C(n, r) = =
r! r! (n r)!
C(n, r) = C(n, n r) .
or
1. Choose X . . . . . . . . . . . . . . . . . . . . 1 way
2. Choose r 1 objects from
the remaining n . . . . . . . . . . . . . . C(n, r 1) ways
Comments.
This type of argument, where we prove that two
expressions are equal by showing that they are both the
answer to the same counting problem, is known as a
combinatorial proof .
Alternatively, both identities can be proved by writing
C(n, r) in terms of factorials as on page 22. Exercise.
Do so!
Where have you seen the second identity from the
previous lemma before?
MATH1081 Discrete Mathematics 4.25: Binomial theorem
So, the numbers C(n, r) are just those that appear in the
Binomial Theorem, or in Pascals Triangle. In fact, the second
identity on the previous page is just the rule which defines
Pascals Triangle. Because of this connection, the numbers
C(n, r) are often known as the binomial coefficients.
MATH1081 Discrete Mathematics 4.26: Sets
Lets now solve this problem correctly. First well use the
subtraction rule: the total number of tenletter words (with
repeated letters allowed) is 2610 , and from this we need to
subtract the number of words with no X or no Y or no Z.
It is best to treat this as a problem in counting the elements
of sets. Consider a universal set
U = { tenletter words }
and three subsets of U:
A = { tenletter words with no X }
B = { tenletter words with no Y }
C = { tenletter words with no Z } .
The words we dont want to count are those which are elements
of A B C. In part 1 of Discrete Mathematics you learned
the inclusion/exclusion formula for two sets,
|A B| = |A| + |B| |A B| ;
here we need the corresponding formula for three sets,
|A B C| = |A| + |B| + |C|
|A B| |A C| |B C|
+ |A B C| .
. . . continued
MATH1081 Discrete Mathematics 4.29: . . . continued
= |U| |A B C|
= |U| |A| |B| |C|
+ |A B| + |A C| + |B C|
|A B C|
= 2610 3 2510 + 3 2410 2310 .
MATH1081 Discrete Mathematics 4.30: Comments
Comments.
The principle of inclusion/exclusion is a formula for
counting the elements in a union of sets. So, you should
always begin an inclusion/exclusion problem by defining
a universal set and appropriate subsets.
There is an inclusion/exclusion formula for any (finite)
number of sets, and the coefficients are always 1. To
count the number of elements in a union of sets, add the
number in each set, then subtract the number in every
possible intersection of two sets, then add the number in
every possible intersection of three sets, and so on. For
example,
|S H D| = 0 and |S H D C| = 0 ,
= mn m(m 1)n
+ C(m, 2)(m 2)n C(m, 3)(m 3)n +
m
X
= (1)k C(m, k)(m k)n .
k=0
W1 O1 O2 L1 L2 O3 O4 M1 O5 O6 L3 O7 O8 .
W1 O1 O2 L3 L2 O3 O4 M1 O5 O6 L1 O7 O8
and
W1 O1 O2 L2 L3 O3 O4 M1 O5 O6 L1 O7 O8 ,
which are actually all the same. There will be 3! words like
this, obtained by rearranging the three Ls; therefore we must
divide our previous answer of 13! by 3!. Similarly we must
divide by 8! to take account of the repeated Os. As the
available letters are one W, eight Os, three Ls and one M, the
number of arrangements is
13!
.
1! 8! 3! 1!
The factors of 1! in the denominator can be omitted as they
do not alter the number, but its better to include them as
they help to clarify the pattern.
MATH1081 Discrete Mathematics 4.35: Notes
S T U
| | | | | | | | | | | | | | | | | | | | | | | | |
C(n + r 1, n 1) .
MATH1081 Discrete Mathematics 4.39: Summary
Repetitions
allowed not allowed
relevant nr P (n, r)
Order n + r 1 n
irrelevant
n1 r
MATH1081 Discrete Mathematics 4.40: Equations
. . . continued
MATH1081 Discrete Mathematics 4.41: Solutions (c) and (d)
. . . continued
MATH1081 Discrete Mathematics 4.42: (d) again, and (e)
| | | |
| | | |
x1 = 6 , x2 = 6 , x3 = 4 , x4 = 5 , x5 = 5 .
(m + a + t + h)1081
Examples.
1. What is the probability of guessing the correct numbers
in Lotto?
Solution. In Lotto one has to pick six numbers from
45. The order of choices is not important, and the same
number cannot be chosen more than once. So the number
of possible choices is C(45, 6). There is only one correct
choice, so the probability of guessing correctly is
1 1
= = 0000000123 .
C(45, 6) 8145060
MATH1081 Discrete Mathematics 4.45: Examples
C(100, 60)
.
2100
Similarly, the probability of obtaining 60 or more heads is
3. Five dice are rolled. What is the probability that the sum
of the numbers obtained is 26?
Solution. Each die shows one of the numbers 1 to 6.
We are rolling five different dice, so the same number
may show up more than once and the order of results is
important. Therefore there are 65 outcomes altogether.
To count the number in which the total is 26, let xk be
the number on the kth die, where k = 1, 2, 3, 4, 5. Then
we require
x1 + x2 + x3 + x4 + x5 = 26
C(8, 4)
.
65
| U| |S2 S3 S5 S7 |
= | U| |S2 | |S3 | |S5 | |S7 |
+ |S2 S3 | + |S2 S3 S5 |
+ |S2 S3 S5 S7 |
= | U| |S2 | |S3 | |S5 | |S7 |
+ |S6 | + |S30 | + |S210 |
= 1000 500 333 200 142
+ 166 + 100 + 71 + 66 + 47 + 28
33 23 14 9 + 4
= 228 .
(x)
1 as x .
x/ log x
If you want to know just how close to 1 this ratio is, we have
the inequalities
2 (x) 17
< < ,
3 x/ log x 10
true for all x 5. A more complicated but very accurate
approximation is Z x
dt
(x) .
2 log t
For some details about this see MATH1131/1141 Calculus,
chapter 8, problem 28.
Examples.
Among any 27 people, there must be two or more whose
surnames have the same initial. Proof. We have 26
boxes (letters of the alphabet), and 27 objects
(people). Put each person in the box corresponding to
their initial. Since there are more objects than boxes,
there must be a box with more than one object in it. That
is, there are two or more people with the same initial.
In the game of bridge a hand consists of 13 cards. If I play
1000 hands of bridge (dealt from a full pack every time)
then there must be two with the same suit distribution,
that is, the same number of spades, the same number
of hearts, the same number of diamonds and the same
number of clubs. Proof. Suit distributions correspond to
nonnegative integer solutions of the equation
s + h + d + c = 13 .
The number of possibilities is C(16, 3) = 560, and since
I played more than this number of hands I must have
received the same suit distribution more than once.
MATH1081 Discrete Mathematics 4.52: Another example
Examples.
Improving on the above example, we can calculate that
1000000 is more than 2732 times 366, and so in a city of
a million people there must be 2733 or more who share
the same birthday.
MATH1081 Discrete Mathematics 4.54: More examples
and so on.
MATH1081 Discrete Mathematics 4.57: . . . continued
m log2 (n!) .
y y = log x
0 1 2 3 4 n2 n1 n x
32 31
3C(32, 2) = 3 = 1488 = 32 (46 12 )
2
matches, one of them must have won at least 47 matches. So,
for a team to reach the finals it must win at least 47 matches
(out of 123); in other words, a team with 46 or fewer wins
cannot possibly make the finals, regardless of the results of
other matches.
MATH1081 Discrete Mathematics 4.61: Recurrences
RECURRENCE RELATIONS
Suppose that we wish to solve a counting problem involving
an unknown parameter n. For example,
how many nletter words contain the subword XY ?
how many saturated hydrocarbon molecules are there
with n carbon atoms?
A powerful method of solving some problems of this type is to
set up and solve a recurrence relation.
That is, let an be the answer to the problem; find an equation
relating an to the previous values an1 , an2 and so on; use
this equation to derive a formula for an directly in terms of n.
MATH1081 Discrete Mathematics 4.62: Vending machine
0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144 , . . . .
an = an1 + an2 .
a0 = 1 , a1 = 2 .
an =
or, equivalently,
an = ran1 with a0 = A
has solution
an = Arn .
an + pan1 + qan2 = 0 . ()
rn + prn1 + qrn2 = 0 ,
Comments.
The quadratic () is called the characteristic equation
of the recurrence ().
A similar method will work for recurrences of higher
order. In general, a recurrence of order k will have a
characteristic equation whose left hand side involves a
polynomial of degree k.
MATH1081 Discrete Mathematics 4.70: Linear combinations
an = An + B n
2 + p + q = 0 and 2 + p + q = 0 ,
an + pan1 + qan2
= (An + B n )
+ p(An1 + B n1 ) + q(An2 + B n2 )
= A(n + pn1 + qn2 ) + B( n + p n1 + qn2 )
= An2 (2 + p + q) + B n2 ( 2 + p + q)
=0.
MATH1081 Discrete Mathematics 4.71: General solution
Examples.
Find the general solution of the recurrence
an 5an1 14an2 = 0 .
r2 5r 14 = 0 ,
an = A 7n + B(2)n .
an = 7n + 3(2)n .
an = 6an1 9an2 , a0 = 5 , a1 = 6 .
r2 6r + 9 = 0
A = 5 and 3(A + B) = 6 ,
an = (7n 5)3n .
MATH1081 Discrete Mathematics 4.75: Exercises
a0 = 4 , a1 = 8 , a2 = 10 .
r3 + 2r2 13r + 10 = 0 ;
(r 1)(r2 + 3r 10) = 0 .
an = A + B2n + C(5)n .
A + B + C = 4 , A + 2B 5C = 8 , A + 4B + 25C = 10 .
an = 9 6 2n + (5)n ,
an = an1 ()
an an1 = 0 ;
r =0
an = 7an1 + 18 4n1 ,
an 7an1 = 9
2 4n .
an = 7n+1 6 4n .
MATH1081 Discrete Mathematics 4.80: Comments
Comments.
The above procedure will involve some work in splitting
and recombining the matrices, but we have ignored
this because it will not require any actual arithmetic.
However a full analysis of the algorithm should take these
operations into account too!
Exercise. Show that the number of calculations required
to multiply two matrices of size 2n by 2n by the obvious
method is
b n = 2 8n 4n .
(You dont need to use recursion, just carefully count all
the necessary operations.) Using Maple, or otherwise,
show that Strassens method takes fewer operations
whenever n 10.
For further details of Strassens algorithm you could read
web.maths.unsw.edu.au/~angell/2410/section1.ps
or just search for strassen matrix multiplication on
the web.
There are more recent algorithms which are even better
than Strassens!
The term constant coefficients refers to the coefficients
of an and an1 . It doesnt matter that the right hand
side is not constant.
MATH1081 Discrete Mathematics 4.81: Solving inhomogeneous recurrences
. . . continued
MATH1081 Discrete Mathematics 4.84: . . . continued
A + B + 5 = 3 and 3A + 4B + 5 = 1 ,
that is,
A + B = 2 and 3A + 4B = 4 ,
so A = 4 and B = 2. Therefore, the solution of the
inhomogeneous initial value problem is
an = 4 3n + 2 4n + 5 .
hn = A3n + B4n .
that is,
6cn 17c = 30n ;
comparing the coefficients of n gives 6c = 30, so c = 5 and a
particular solution is pn = 5n.
Wrong! Why?
6c = 30 and 17c = 0 ;
pn = cn + d ;
substituting gives
6c = 30 and 17c + 6d = 0 ;
85
hence c = 5 and d = 6 , a particular solution is
85
pn = 5n + 6 ,
an = hn + pn = A3n + B4n + 5n + 85
6 .
MATH1081 Discrete Mathematics 4.87: Exercise
an an1 2an2 = 6n 1 .
an 7an1 + 12an2 = 3 2n ,
pn = c2n .
Substituting,
4c 14c + 12c = 12
an = A3n + B4n + 6 2n ;
A + B + 6 = 5 and 3A + 4B + 12 = 6 ,
so A = 2, B = 3 and thus
an = 2 3n 3 4n + 6 2n .
MATH1081 Discrete Mathematics 4.89: Products
pn = (cn + d)2n .
pn = (6n + 30)2n .
MATH1081 Discrete Mathematics 4.90: Exercise
and also of
an an1 2an2 = 2n .
MATH1081 Discrete Mathematics 4.91: A difficulty
pn = c2n ,
an an1 2an2 = 0
has a solution
an = A(1)n + B2n
for any constants A and B. In particular, taking A = 0 and
B = c we see that our guess pn = c2n is a solution of the
homogeneous equation. This means, by definition, that when
we substitute an = pn , the left hand side will simplify to zero,
and cannot equal the 2n on the right hand side.
. . . continued
MATH1081 Discrete Mathematics 4.92: . . . resolved
we shall try
pn = cn2n .
Substituting into the recurrence,
6c = 4 .
pn = 32 n2n ,
an 7an1 = 9
2 4n with a0 = 1 .
an = 7an1 ,
hn = A7n .
4c 7c = 18 .
an = A7n 6 4n .
an = 7 7n 6 4n = 7n+1 6 4n ,
Exercises.
What happens to vn as n ? What does this mean in
economic terms? Does it make sense?
Generalise this problem by taking the regular payment to
be p dollars and the interest rate i. You should obtain
the present value of an annuity formula
p 1
vn = 1 ,
i (1 + i)n
an = 98an1 + 99an2 .
a1 = 1 and a2 = 98 .
MATH1081 Discrete Mathematics 4.100: Exercises
Exercises.
Solve this recurrence to show that
99n (1)n
an = .
100