university of hawaii ics141: discrete mathematics for ...janst/141/lecture/12-summations.pdf · ics...

25
12-1 ICS 141: Discrete Mathematics I – Fall 2011 University of Hawaii ICS141: Discrete Mathematics for Computer Science I Dept. Information & Computer Sci., University of Hawaii Jan Stelovsky based on slides by Dr. Baek and Dr. Still Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by McGraw-Hill

Upload: others

Post on 24-Jun-2020

10 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-1 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii

ICS141: Discrete Mathematics for Computer Science I

Dept. Information & Computer Sci., University of Hawaii

Jan Stelovsky based on slides by Dr. Baek and Dr. Still

Originals by Dr. M. P. Frank and Dr. J.L. Gross Provided by McGraw-Hill

Page 2: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-2 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii

Lecture 12

Chapter 2. Basic Structures 2.4 Sequences and Summations

Page 3: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-3 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Summation Notation n  Given a sequence {an}, an integer lower bound

(or limit) j ≥ 0, and an integer upper bound k ≥ j, then the summation of {an} from aj to ak is written and defined as follows:

n  Here, i is called the index of summation.

kjj

k

jii aaaa +++= +

=∑ ...1

∑∑∑===

==k

jll

k

jmm

k

jii aaa

Page 4: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-4 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Generalized Summations n  For an infinite sequence, we write:

n  To sum a function over all members of a set X = {x1, x2,…}:

n  Or, if X = {x| P(x)}, we may just write:

++=∑∈

)()()( 21 xfxfxfXx

++=∑ )()()( 21)(

xfxfxfxP

++= +

=∑ 1jjjii aaa

Page 5: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-5 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii

=++++1001

41

31

211

( )

3217105

)116()19()14(

)14()13()12(1 2224

2

2

=

++=

+++++=

+++++=+∑=ii

Simple Summation Example

∑=

100

1

1i i

n 

n 

Page 6: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-6 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii More Summation Examples n  An infinite sequence with a finite sum:

n  Using a predicate to define a set of elements to sum over:

87492594

7532 2222

10(

2

=+++=

+++=∑<

∧x

xx

prime) is

241

211222 10

0

=+++=++= −∞

=

−∑ i

i

Page 7: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-7 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii

ii

iiiiin

8)2(4

222222

1=⋅=

+++=∑−=

62322223

1=⋅=++=∑

=n

Summation Manipulations n  Some handy identities for summations:

n  Summing constant value

cijcj

in⋅+−=∑

=

)1(

Number of terms in the summation

Page 8: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-8 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Summation Manipulations n  Distributive law

∑∑==

=j

in

j

innfcncf )()(

( )

( )

=

=

=

++⋅=

⋅+⋅+⋅=⋅

3

1

2

222

2223

1

2

4

3214

3424144

n

n

n

n

Page 9: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-9 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Summation Manipulations n  An application of commutativity

( ) ∑ ∑∑= ==

+=+j

in

j

in

j

inngnfngnf )()()()(

( )

∑ ∑

= =

=

+=

⋅+⋅+⋅+++=

⋅++⋅++⋅+=+

4

2

4

2

4

2

2

)423222()432(

)424()323()222(2

n n

n

nn

nn

Page 10: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-10 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Index Shifting

22224

1

2 4321 +++=∑=ii

∑∑+

+==

−=nm

njk

m

jinkfif )()(

n  Let k = i + 2, then i = k – 2

( ) ( )

( ) ( ) ( ) ( )2222

6

3

224

21

2

26252423

22

−+−+−+−=

−=− ∑∑=

+

+= kkkk

Page 11: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-11 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii More Summation Manipulations n  Sequence splitting

∑∑

==

=

+=

++++=

++++=

4

3

32

0

3

33333

333334

0

3

)43()210(

43210

ii

i

ii

i

kmjifififk

mi

m

ji

k

ji<≤+= ∑∑∑

+===

if 1)()()(

Page 12: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-12 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii More Summation Manipulations n  Order reversal

∑∑==

−=k

i

k

iikfif

00

)()(

( )∑

=

=

−=

−+−+−+−=

+++=

3

0

3

3333

33333

0

3

3

)33()23()13()03(

3210

i

i

i

i

Page 13: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-13 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Example: Geometric Progression

n  A geometric progression is a sequence of the form a, ar, ar2, ar3, …, arn ,… where a,r∈R.

n  The sum of such a sequence is given by:

n  We can reduce this to closed form via clever manipulation of summations...

∑=

=n

i

iarS0

Page 14: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-14 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii

n  Here we go...

Geometric Sum Derivation

...1

1

1

11

1

1

1

1

)1(1

0

1

0

1

000

0

=+⎟⎟⎠

⎞⎜⎜⎝

⎛=+⎟⎟

⎞⎜⎜⎝

⎛=

===

====

=

+

=

+

+==

+

=

+

=

−+

=

+

====

=

∑∑∑

∑∑∑

∑∑∑∑

nn

j

jn

nj

jn

j

j

n

j

jn

j

jn

i

i

n

i

in

i

in

i

in

i

i

n

i

i

arararar

ararar

rararrrararrrS

arS

Page 15: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-15 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Derivation Example Cont...

)1()1(

)(

11

0

1

1

0

0

01

1

0

1

1

001

1

−+=−+⎟⎠

⎞⎜⎝

⎛=

−+⎟⎠

⎞⎜⎝

⎛+⎟⎠

⎞⎜⎝

⎛=

−+⎟⎠

⎞⎜⎝

⎛+=

+⎟⎠

⎞⎜⎝

⎛+−=+⎟

⎞⎜⎝

⎛=

++

=

+

==

+

=

+

=

+

=

∑∑

∑∑

nnn

i

i

nn

i

i

i

i

nn

i

i

nn

i

inn

i

i

raSraar

aararar

arararar

ararararararrS

Page 16: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-16 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Concluding Long Derivation...

( )

anaaarSr

rrraS

rarS

raSrS

raSrS

n

i

n

i

in

i

i

n

n

n

n

)1(111

111

)1()1(

)1(

)1(

000

1

1

1

1

+=⋅====

≠−

−=

−=−

−=−

−+=

∑∑∑===

+

+

+

+

, When

n whe

Page 17: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-17 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Example: Impress Your Friends n  Boast, “I’m so smart; give me any 2-digit

number n, and I’ll add all the numbers from 1 to n in my head in just a few seconds.”

n  I.e., Evaluate the summation:

n  There is a simple closed-form formula for the result, discovered by Gauss at age 10! n  And frequently rediscovered by many…

∑=

n

ii

1

Page 18: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-18 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Gauss’ Trick, Illustrated n  Consider the sum:

1+2+…+(n/2)+((n/2)+1)+…+(n-1)+n

n  We have n/2 pairs of elements, each pair summing to n+1, for a total of (n/2)(n+1).

n+1

n+1

n+1

Page 19: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-19 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Symbolic Derivation of Trick

...)1()1(

))1(()(

))1()))1(((

))1((

1111

11

)1(

01

)1(

01

)1(

0111

2

11

=−++⎟⎠

⎞⎜⎝

⎛=−++⎟

⎞⎜⎝

⎛=

−−+⎟⎠

⎞⎜⎝

⎛=−+⎟

⎞⎜⎝

⎛=

++−+−+⎟⎠

⎞⎜⎝

⎛=

+++⎟⎠

⎞⎜⎝

⎛=+⎟

⎞⎜⎝

⎛==

∑∑∑∑

∑∑∑∑

∑∑

∑∑∑∑∑∑

==

==

==

+−

==

+−

==

+−

==+====

k

l

k

i

kn

l

k

i

kn

l

k

i

kn

j

k

i

kn

j

k

i

kn

j

k

i

n

ki

k

i

k

i

n

i

lnilni

lnijni

kjkni

kjiiiii

For case where n is even… k = n/2

Page 20: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-20 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Concluding Gauss’ Derivation

n  So, you only have to do 1 easy multiplication in your head, then cut in half.

n  Also works for odd n (prove this at home).

2)1(

)1(2

)1()1(

)1()1(

1

1111

+=

+=+=+=

−++=−++⎟⎠

⎞⎜⎝

⎛=

∑∑∑∑

=

====

nn

nnnkn

iniinii

k

i

k

i

k

i

k

i

n

i

Page 21: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-21 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Some Shortcut Expressions

Geometric sequence

Gauss’ trick

Quadratic series

Cubic series

Page 22: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-22 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Using the Shortcuts n  Example: Evaluate ∑

=

100

50

2

kk

.925,297425,40350,338

6995049

6201101100

49

1

2100

1

2100

50

2

100

50

249

1

2100

1

2

=

−=

⋅⋅−

⋅⋅=

−⎟⎠

⎞⎜⎝

⎛=

+⎟⎠

⎞⎜⎝

⎛=

∑∑∑

∑∑∑

===

===

kkk

kkk

kkk

kkkn  Use series splitting.

n  Solve for desired summation.

n  Apply quadratic series rule.

n  Evaluate.

Page 23: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-23 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii

n  The sets A and B have the same cardinality if and only if there is a one-to-one correspondence from A to B.

n  A set that is either finite or has the same cardinality as the set of positive integers is called countable.

n  A set that is not countable is called uncountable.

n  Example: Show that the set of odd positive integers is a countable set.

Cardinality

A one-to-one correspondence between Z+ and the set of odd positive integers.

Consider the function f(n) = 2n – 1 from Z+ to the set of odd positive integers

Page 24: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-24 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii

n  a1, a2,…,an,… is one-to-one mapping f: Z+→ S where a1=f(1), a2=f(2),…, an=f(n),…

n  Example: Show that the set of positive rational numbers is countable (see figure)

Cardinality (cont.) n  An infinite set S is countable iff it is possible to list the

elements of the set in a sequence (indexed by the positive integers)

Page 25: University of Hawaii ICS141: Discrete Mathematics for ...janst/141/lecture/12-Summations.pdf · ICS 141: Discrete Mathematics I – Fall 2011 12-3 Summation Notation University of

12-25 ICS 141: Discrete Mathematics I – Fall 2011

University of Hawaii Summation Manipulations n  Useful identities:

( )∑∑

∑∑

∑∑∑

==

==

+===

+−=

−=

<≤+=

k

i

k

i

k

i

k

i

k

mi

m

ji

k

ji

ififif

ikfif

kmjififif

1

2

1

00

1

)2()12()(

)()(

)()()( if

(Grouping.)

(Order reversal.)

(Sequence splitting.)