Download MACM 101 — Discrete Mathematics I Outline Solutions to Exercises

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Basis (linear algebra) wikipedia , lookup

Transcript
MACM 101 — Discrete Mathematics I
Outline Solutions to Exercises on Functions and Induction
1. Is the function f : Z → Z defined as f (n) = n3 one-to-one?
No, because f (2) = 33 = 1 and f (3) = 43 = 1.
2. Determine whether or not the function f : Z × Z → Z is onto, if f ((m, n)) = mn.
It is onto. To show that we have to find, given an integer b, a pair (m, n) such that mn = b. Clearly, we can
choose m = b and n = 1.
3. Let f (x) = ax2 and g(x) = bx + c, where a, b, and c are constants. Compute f ◦ g and g ◦ f . Determine
for which constants a, b, and c it is true that f ◦ g = g ◦ f .
First, compute f ◦ g and g ◦ f :
f ◦ g(x)
= f (g(x)) = a · (g(x))2 = a(bx + c)2 = ab2 x2 + 2abx + ac2
g ◦ f (x)
= g(f (x)) = b · f (x) + c = b(ax2 ) + c = abx2 + c.
Now, let us express the condition f ◦ g = g ◦ f :
(f ◦ g)(x)
2 2
2
ab x + 2abx + ac
=
(g ◦ f )(x)
= abx2 + c.
Thus, the equality f ◦ g = g ◦ f holds if and only if the polynomials ab2 x2 + 2abx + ac2 and abx2 + c are equal
for all integer x. It is possible only if the coefficients of the corresponding powers of x are equal. Thus we have
ab2 = ab, 2ab = 0, and ac2 = c.
Consider the second equation. There are two options: a = 0 and b = 0. Note that the first equation is true in
both cases.
Suppose a = 0. Then the third equation implies c = 0. So, if a = c = 0 and b ∈ Z then the desired equality is
true.
Now, let b = 0. From ac2 = c we obtain that either c = 0 or ac = 1. Therefore if b = c = 0, a ∈ Z, or b = 0,
a = 1c , b ∈ Z − {0}, then the desired equality is true.
4. If g and f ◦ g are both onto, does it follow that f is onto?
Yes. We prove by contrapositive: we assume that f is not onto, and show that f ◦ g also is onto. Let A and B
be the domain and codomain of g, respectively, and let B and C be the domain and codomain of f , respectively.
Since f is not onto, there is c ∈ C, such that f (b) = c for no b ∈ B. But then for any a ∈ A
(f ◦ g)(a) = f (g(a)) 6= c,
because g(a) ∈ B. Thus, f ◦ g is not onto.
5. Show that the function f : R − {1} → R − {2} defined by f (x) =
function..
2x−3
x−1
is a bijection, and find the inverse
Note, first of all, that f is a function from R − {1}, meaning that for any a ∈ R − {1} the number f (a) is
defined. Clearly, f (1) is not defined. Next we prove that f is one-to-one by showing that if f (a) = f (b) for
1
some a, b ∈ R − {1} then a = b:
f (a) = f (b)
2a − 3
2b − 3
=
a−1
b−1
(2a − 3)(b − 1) = (a − 1)(2b − 3)
2ab − 2a − 3b + 3
a
=
2ab − 2b − 3a + 3
= b.
Thus, f is one-to-one. To show that f is onto we take any b ∈ R−{2}, and find a ∈ R−{1} such that f (a) = b.
f (a) =
2a − 3
=
a−1
2a − 3 =
a
=
b
b
ab − b
b−3
.
b−2
Thus, the required number a exists, and f is onto. Moreover, this computation gives us the reverse function:
f −1 (x) =
x−3
.
x−2
6. Fibonacci numbers F1 , F2 , F3 , . . . are defined by the rule: F1 = F2 = 1 and Fk = Fk−2 + Fk−1 for k > 2.
Lucas numbers L1 , L2 , L3 , . . . are defined in a similar way by the rule: L1 = 1, L2 = 3 and Lk =
Lk−2 + Lk−1 for k > 2.
Show that Fibonacci and Lucas numvers satisfy the following equality for all n ≥ 2
Ln = Fn−1 + Fn+1 .
We use induction. Let P (n) denote this equality for the integer n.
Basis case. P (2) and P (3) mean the equalities L2 = 3 = 1 + 2 = F1 + F3 and L3 = 4 = 1 + 3 = F2 + F4 .
Inductive step. Suppose that P (k − 1) and P (k) is true, that is,
Lk−1 = Fk−2 + Fk ,
Lk = Fk−1 + Fk+1 .
We have to prove P (k + 1):
Lk+1 = Fk + Fk+2 .
Using the definitions of Ln and Fn , and the induction hypothesis
Lk+1
= Lk−1 + Lk
=
(Fk−2 + Fk ) + (Fk−1 + Fk+1 )
=
(Fk−2 + Fk−1 ) + (Fk + Fk+1 )
= Fk + Fk+2 .
7. Prove that for every positive integer n
12 − 22 + 32 − . . . + (−1)n−1 n2 = (−1)n−1
2
n(n + 1)
.
2
We use induction. Let P (n) denote this equality for the integer n.
Basis case. P (1) means the equality 12 = (−1)( 1 − 1) 1(1+1)
, which is obviously true.
2
Inductive step. Suppose that P (k) is true, that is,
12 − 22 + 32 − . . . + (−1)k−1 k 2 = (−1)k−1
k(k + 1)
.
2
We have to prove P (k + 1):
12 − 22 + 32 − . . . + (−1)k−1 k 2 + (−1)k (k + 1)2 = (−1)k
(k + 1)(k + 2)
.
2
We have
12 − 22 + 32 − . . . + (−1)k−1 k 2 + (−1)k (k + 1)2
k(k + 1)
+ (−1)k (k + 1)2
= (−1)k−1
2
k
= (−1)k−1 (k + 1) − k − 1
2
k
= (−1)k−1 (k + 1) − − 1
2
(k + 1)(k + 2)
= (−1)k
.
2
8. In a magic trick four playing cards were stacked together, three of them face up and one face down, with a
heart at the bottom, then a club, then a diamond, and then a spade (facing down). There are three ways in
which the packet of cards is allowed to be mixed: The packet can be cut, the top two cards can be turned
over as one, or the entire packet can be turned over together. Prove that for any n ≥ 0 after n allowed
shuffles there will be exactly one card facing the wrong way, that is, different from the other three.
Denote by P (n) the statement that after n shuffles exactly one card faces the wrong way.
Basis step. P (0) is true, as only a spade faces down, while all other cards face up.
Inductive step. Suppose that P (k) is true, that is, after k shuffles exactly one card faces the wrong way. The
next shuffle can be one of the three allowed: The packet can be cut, the top two cards can be turned over as one,
or the entire packet can be turned over together. We consider them one by one.
Splitting the packet does not change the orientation of the cards, and so preserves the property.
Turning the entire packet changes the orientation of all cards, and therefore preserves the property. Say, if
previously 3 cards were facing down and 1 was facing up, then after the shuffle three will face up, and one
down.
consider turning over the top two cards. There are two possibilities. First the wrongly facing card can be among
the two top. Then it gets oriented the same way as the majority of the cards, and the other card on top gets
oriented the wrong way. Second, if the card facing the wrong way is not among the top two, the after the shuffle
this card and the two top cards face the same way, while the remaining card face the other way.
9. Suppose you begin with a pile of n stones and split this pile into n piles of one stone each by successively
splitting a pile of stones into two smaller piles. Each time you split a pile you multiply the number of stones
in each of the two smaller piles you form, so that if these piles have r and s stones in them, respectively,
you compute rs. Show that no matter how you split the piles, the sum of the products computed at each
.
step equals n(n−1)
2
Let us denote by P (n) the statement that the sum of products is n(n−1)
.
2
Basis step. Obviously, if we have a pile of 2 stones we have to split it once into piles with r = s = 1 stones.
Thus the sum of products (there is only one product rs) equals 1, that proves P (2).
3
Inductive step. Suppose P (2), P (3), . . . , P (k) are true. Take a pile with k + 1 stones and split it arbitrarily. We
obtain two piles, let us denote the number of stones in the first pile by r and that in the second one by s. Clearly,
r, s ≤ k and r + s = k + 1. Therefore, by the inductive hypothesis, the sum of products for the first pile equals
r(r−1)
, and for the second one — s(s−1)
. Together with the first product rs this gives
2
2
rs+
r(r − 1) s(s − 1)
2rs + r2 + s2 − r − s
(r + s)2 − (r + s)
(k + 1)2 − (k + 1)
(k + 1)k
+
=
=
=
=
.
2
2
2
2
2
2
10. A complete binary tree is a graph defined through the following recursive definition.
Basis step: A single vertex is a complete binary tree.
Inductive step: If T1 and T2 are disjoint complete binary trees with roots r1 , r2 , respectively, the the graph
formed by starting with a root r, and adding an edge from r to each of the vertices r1 , r2 is also a complete
binary tree.
The set of leaves and the set of internal vertices of a complete binary tree can also be defined recursively.
Basis step: The root r is a leaf of of the complete binary tree with exactly one vertex r. This tree has no
internal vertices.
Inductive step: The set of leaves of the tree T built from trees T1 , T2 is the union of sets of leaves of T1 and
the set of leaves of T2 . The internal vertices of T are the root r of T and the union of the set of internal
vertices of T1 and the set of internal vertices of T2 .
Use structural induction to show that `(T ) the number of leaves of a complete binary tree T , is one more
than i(T ), the number of internal vertices of T .
Let P (T ) denote the statement that the number `(T ) of leaves is less than 2h(T ) .
Basis step. Let T contains only one vertex. Then by the basis step of the definition `(T ) = 1 and h(T ) = 0, so,
2h(T ) = 1. Thus P (T ) is true.
Inductive step. Let T is built from trees T1 , T2 as described in the definition and suppose that P (T1 ) and P (T2 )
are true. Again by the definition `(T ) = `(T1 ) + `(T2 ) and h(T ) = max(h(T1 ), h(T2 )) + 1. Finally, we get
`(T ) = `(T1 ) + `(T2 ) ≤ 2h(T1 ) + 2h(T2 ) ≤ 2 · 2max(h(T1 ),h(T2 )) = 2max(h(T1 ),h(T2 ))+1 = 2h(t) ,
as required.
4