ps7 Sol
ps7 Sol
ps7 Sol
as a closed-form function of n.
Solution. We use the derivative method. Let us start with the following formula, derived
in lecture (for x 6= 1):
n
X
i x − (n + 1)xn+1 + nxn+2
ix =
i=0
(1 − x)2
n
−1
X (1 − (n + 1)2 xn + n(n + 2)xn+1 )(1 − x)2 − (x − (n + 1)xn+1 + nxn+2 )(2(1 − x)(−1))
x i2 xi =
i=0
(1 − x)4
(1 − (n + 1)2 xn + n(n + 2)xn+1 )(1 − x) + 2(x − (n + 1)xn+1 + nxn+2 )
=
(1 − x)3
1 − (n + 1)2 xn + n(n + 2)xn+1 − x + (n + 1)2 xn+1 − n(n + 2)xn+2
=
(1 − x)3
2x − 2(n + 1)xn+1 + 2nxn+2
+
(1 − x)3
1 + x − (n + 1)2 xn + (n(n + 2) + (n + 1)2 − 2(n + 1))xn+1 + (2n − n(n + 2))xn+2
=
(1 − x)3
1 + x − (n + 1)2 xn + (2n2 + 2n − 1)xn+1 − n2 xn+2
= .
(1 − x)3
2 Problem Set 7
n
22k−1 ?
Q
(a) [5 pts] What is the product of the first n odd powers of two:
k=1
Solution. Pn Pn Pn 2
Πnk=1 22k−1 = 2 k=1 2k−1
= 22 k=1 k− k=1 1
= 2n(n+1)−n = 2n
Solution.
n X
m n m
!
X X X
3i+j = 3i · 3j
i=0 j=0 i=0 j=0
m
! n
!
X X
j i
= 3 · 3
j=0 i=0
m+1 n+1
3 −1 3 −1
= ·
2 2
Solution.
n X
n n X
n
! n X
n
!
X X X
(i + j) = i + j
i=1 j=1 i=1 j=1 i=1 j=1
n
! n
!
X X n(n + 1)
= ni +
i=1 i=1
2
2
2n (n + 1)
=
2
2
= n (n + 1)
Problem Set 7 3
Solution.
n Y
n n
! n
!
Y Y Y
2i · 3j = 2ni 3nj
i=1 j=1 i=1 j=1
Pn Pn
n i=1 i n j=1 j
=2 3
n2 (n+1)/2 2 (n+1)/2
=2 3n
Problem 3. [10 points]
(a) [6 pts] Use integration to find upper and lower bounds that differ by at most 0.1 for the
following sum. (You may need to add the first few terms explicitly and then use integrals to
bound the sum of the remaining terms.)
∞
X 1
i=1
(2i + 1)2
(b) [4 pts] Assume n is an integer larger than 1. Which of the following inequalities, if any,
hold. You may find the graph helpful.
n
X Z n
1. ln(i + 1) ≤ ln(x + 2)dx
i=1 0
Xn Z n
2. ln(i + 1) ≤ ln 2 + ln(x + 1)dx
i=1 1
Problem 4. [15 points] There is a bug on the edge of a 1-meter rug. The bug wants to
cross to the other side of the rug. It crawls at 1 cm per second. However, at the end of
each second, a malicious first-grader named Mildred Anderson stretches the rug by 1 meter.
Assume that her action is instantaneous and the rug stretches uniformly. Thus, here’s what
happens in the first few seconds:
Mildred stretches the rug by 1 meter, which doubles its length. So now there are 2 cm
behind the bug and 198 cm ahead.
The bug walks another 1 cm in the next second, leaving 3 cm behind and 197 cm
ahead.
Then Mildred strikes, stretching the rug from 2 meters to 3 meters. So there are now
3 · (3/2) = 4.5 cm behind the bug and 197 · (3/2) = 295.5 cm ahead.
Problem Set 7 5
(a) [5 pts] During second i, what fraction of the rug does the bug cross?
Solution. During second i, the length of the rug is 100i cm and the bug crosses 1 cm.
Therefore, the fraction that the bug crosses is 1/100i.
(b) [5 pts] Over the first n seconds, what fraction of the rug does the bug cross altogether?
Express your answer in terms of the Harmonic number Hn .
Solution. The bug crosses 1/100 of the rug in the first second, 1/200 in the second, 1/300
in the third, and so forth. Thus, over the first n seconds, the fraction crossed by the bug
is: n
X 1
= Hn /100
k=1
100k
(This formula is valid only until the bug reaches the far side of the rug.)
(c) [5 pts] Approximately how many seconds does the bug need to cross the entire rug?
Solution. The bug arrives at the far side when the fraction it has crossed reaches 1. This
occurs when n, the number of seconds elapsed, is sufficiently large that Hn /100 ≥ 1. Now
Hn is approximately ln n, so the bug arrives about when:
ln n
≥1
100
ln n ≥ 100
n ≥ e100 ≈ 1043 seconds
Problem 5. [20 points] For each of the following six pairs of functions f and g (parts (a)
through (f)), state which of these order-of-growth relations hold (more than one may hold,
or none may hold):
ln 10
=
ln 2
So f (n) = Ω(g(n)) and f (n) = O(g(n)) and f (n) = Θ(g(n)).
= lim (1/5)n
n→∞
=0
f (n) = 1 + cos πn πn
2
and g(n) = 1 + sin 2
:
For all n ≡ 1 (mod 4), f (n)/g(n) = 0, so f (n) 6= Ω(g(n)). Likewise, for all n ≡ 0
(mod 4), g(n)/f (n) = 0, so f (n) 6= O(g(n)). The quotient never converges to some
particular limit, so no relation holds.
(a) [5 pts]
Either prove or disprove each of the following statements.
n! = O((n + 1)!)
n! = Ω((n + 1)!)
n! = Θ((n + 1)!)
n! = ω((n + 1)!)
n! = o((n + 1)!)
Solution. Observe that n! = (n + 1)!/(n + 1), and thus n! = o((n + 1)!). Thus, n! =
O((n + 1)!) as well, but the remaining statements are false.
n n+e
(b) [5 pts] Show that n! = ω 3
.
n n+e
e n n
= n3
On the other hand, note that 3 3
. Dividing n! by this quantity,
√ n
3e 2π 3
e−1/2
· ,
n e
n+e
we see that since 3 > e, this expression goes to ∞. Thus, n! = ω n3 .
n!
lim>0
n→∞ 2n
n n √ n
√
10
lim 2πn > lim 2πn = ∞
n→∞ 2e n→∞ 2e
So the original limit must also be ∞. This also shows that in fact n! = ω (2n ) And the
same argument can be used to show that n! = ω (10n ) or any other constant base.