Sums and Recurrences Notations: Sum Up First n Odd Integers How

How Do We Find the Value of a Sum?
Sums and Recurrences
Readings: CM Sections 2.1 – 2.2
CSE547: Discrete Mathematics
Fall 2015
One way to find the value of a summation series is to first
express it as a recurrence relation, for which we derive a
closed-form solution.
C HEN -W EI WANG
3 of 16
Notations: Sum Up First n Odd Integers
There are 4 possible ways to express this problem:
1. 1 + 3 + 5 + · · · + (2n
1)
• . . . means to complete the pattern established by surrounding terms.
2. Delimited Form:
n
⌃ 2k
k =1
1 or equivalently
⌃ 2j + 1
j=0
without changing the result.
• Equivalent expressions can also be derived by rewriting the index
bounds and summands.
⌃
1  k  2n ^ k % 2 = 1
k
• The range of index variable is specified by a predicate.
4. Iverson’s Form:
⌃ k · [k odd], where
k
[k odd] =
2 of 16
(
1,
0,
Sn
= {delimited form of Sn }
n
⌃ ak
n 1
• The index variables k and j are dummy variables may be renamed
3. General Form:
Rewriting Sum in Terms of Itself
if 1  k  2n ^ k % 2 = 1;
otherwise.
k =0
= {split the interval [0, n] to [0, n
n 1
⌃ ak +
k =0
1] and [n, n]}
n
⌃ ak
k =n
= {interval
! [n, n] has only one value}
n 1
⌃ ak
k =0
+ an
= {substitute n in the def. of Sn by n
Sn 1 + an
1}
The next step, then, is to redefine Sn as a recurrence relation.
4 of 16
Expressing Sum as a Recurrence Relation
Using the Closed-Form Solution
Recall:
S0 = a0
Sn = Sn
n
⌃ ( + · n) = ↵ + n
k =0
1
+ an for n > 0
Then how do you solve
Say an is an linear expression of n, e.g., 2n + 4, then how can
we generalize the above recurrence relation?
1
+( +
n · (n + 1)
2
n
k =0
0
=
⌃ (3k + 5) = 5
k =0
5
3
=
=
Therefore:
n
⌃ (3k + 5) = 5 + 5n + 3 ·
k =0
5 of 16
◆
⌃ (3k + 5)?
· n) for n > 0
What is the sort of solution pattern that the above recurrence
relation unfolds into?
✓
n · (n + 1)
2
◆
=
3 2 13
·n +
·n+5
2
2
7 of 16
Unfolding the General Recurrence Relation
R0
R1
R2
R3
...
Rn
What We Have Achieved: Sum to Recurrence
• Given a sum of the general form:
= R0 + ( +
= R1 + ( +
= R2 + ( +
= Rn
1
+(
=
· 1) =
· 2) =
· 3) =
· n)
n
↵
↵+ +
↵+2 +3
↵+3 +6
↵+n +
⌃
k =0
relation:
⌃ k
⇣
+
·n
• To find its value, we first derive its corresponding recurrence
n
= ↵+n +
=
k =1
n·(n+1)
2
!
⌘
That is, we now obtain the closed-form solution for the sum:
✓
◆
n
n · (n + 1)
⌃ ( + · k) = ↵ + n +
2
k =0
6 of 16
✓
This is actually an instance where
↵
R0 = ↵
Rn = Rn
+
R0
Rn
=
=
↵
Rn
1
+( +
· n)
for n > 0
• We then solve this general recurrence relation:
Rn = ↵ + n +
✓
n · (n + 1)
2
◆
• We are then able to apply this solution to instances of the given
sum: e.g.,
n
⌃ (3k + 5)
8 of 16
k =0
Going the Other Way: Recurrence to Sum
From Recurrence to Sum: Tower of Hanoi (2)
By letting Sn = Tn /2n , we rewrote the recurrence
T0
Tn
as
S0
Sn
• Some recurrence relations are hard to solve.
• One strategy is to reduce these recurrence relations to sums,
for which we apply existing methods to evaluate them.
=
=
0
2 · Tn
0
Sn
1
n
=
=
=
=
=
⌃ 2
Recall the solution pattern for Tn as a recurrence relation:
T0
Tn
=
=
0
2 · Tn
+1
1
for n > 0
But it is not quite the general recurrence relation we derived for
a sum Sn :
S0
Sn
=
=
a0
Sn
1
+ an
for n > 0
How about divide both sides by 2n ?
T0 /20
Tn /2n
=
=
0/20
Tn 1 /2n
1
+ 1/2n
for n > 0
Let Sn = Tn /2n , then we obtain an instance of the general
recurrence for sum Sn :
S0
Sn
=
=
0
Sn
1
+2
n
for n > 0
for n > 0
n
for n > 0
k
k =1
1
2
1
2
+ ( 12 )2 + . . . ( 12 )n
+ 12 · 12 + 12 · ( 12 )2 + · · · +
1
2 ·(1
1
1
( 12 )n )
1
2
· ( 12 )n
1
2
( 12 )n
11 of 16
From Recurrence to Sum: Tower of Hanoi (1)
+1
+2
Therefore, Tn = 2n · Sn = 2n
9 of 16
1
which can be reduced to the sum
Sn
10 of 16
=
=
1
{expansion}
{rewriting}
{geo. seq.}
{arithmetic}
1.
From Recurrence to Sum:
Generalizing Tower of Hanoi (1)
The recurrence relation for Tn has the general form:
an Tn = bn Tn
1
+ cn
Recall: to turn Tn to Sn , where we multiply both sides by 2 n .
Similarly, we multiply both sides by a summation factor sn :
sn · an Tn = sn · bn Tn
1
+ sn · cn
To turn the above general recurrence to Sn , the choice of sn
must be such that:
sn bn = sn
1 an 1
Then, by letting Sn = sn an Tn , we reach the sum-recurrence:
12 of 16
Sn = Sn
1
+ sn cn
From Recurrence to Sum:
Generalizing Tower of Hanoi (2)
Sn
=
=
Sn
Sn
...
=
S0 +
=
s0 a0 T0 +
=
s1 b1 T0 +
1
2
+ sn cn
+ sn 1 cn
1
+ sn cn
n
⌃ sk ck
k =1
n
⌃ sk ck
k =1
n
⌃ sk ck
k =1
{recurrence def. of Sn }
{recurrence def. of Sn 1 }
{recurrence def. of S1 }
{Sn = sn an Tn }
{sn bn = sn
Recall that: Sn = sn an Tn
So we finally have:
13 of 16
Sn
1
Tn =
=
sn an
sn an
Index (1)
1 an 1 }
n
s1 b1 T0 +
⌃ sk ck
k =1
Beyond this lecture. . .
!
Notations: Sum Up First n Odd Integers
How Do We Find the Value of a Sum?
Rewriting Sum in Terms of Itself
Expressing Sum as a Recurrence Relation
Unfolding the General Recurrence Relation
Using the Closed-Form Solution
What We Have Achieved: Sum to Recurrence
Going the Other Way: From Recurrence to Sum
From Recurrence to Sum: Tower of Hanoi (1)
From Recurrence to Sum: Tower of Hanoi (2)
From Recurrence to Sum:
Generalizing Tower of Hanoi (1)
From Recurrence to Sum:
Generalizing Tower of Hanoi (2)
15 of 16
Index (2)
Beyond this lecture. . .
• Read the Sections 2.1 and 2.2 in the textbook.
14 of 16
16 of 16