21
Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.1

Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Summations (portions fromConcrete Mathematicsby Graham,

Knuth, Patashnik)CSE 20— Nov. 1, 2005, Day 12

Neil Rhodes

UC San Diego

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.1

Page 2: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

FunctionsGiven f : A → B:

Inverse Image of f

f−1(b) = {a : a ∈ A and f (a) = b}

Coimage is the partition ofA where all elements in ablock map to the same element ofB.

Coimage(f ) = { f−1(b) : b ∈ Image(f )}

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.2

Page 3: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Number of PartitionsGivenS = {a1,a2, . . . ,an}:

• How many partitions ofS are there?• How many partitions of sizek are there?

• If an is in a new block:• If an is in an existing block:

• S(n,k) or {nk} is theStirling number of the second

kind

S(n,k) =

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.3

Page 4: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Calculating S(n,k)1 2 3 4 5

12345

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.4

Page 5: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Number of FunctionsGiven setsA andB, how many functions are there ofthe form f : A → B where|Image(f )| = k?

• How many partitions ofA are there of sizek?• How many images are there of sizek?• How many ways to map the blocks of

Coimage(f ) to Image(f )?

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.5

Page 6: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Summing a Sequence• Specific sum

1+2+3+ · · ·+n−1+n

• General summation of a sequence ofterms:

a1+a2+ · · ·+an

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.6

Page 7: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Sigma Notation• Three-dots notation is vague and wordy.• Sigma notation is more compact:

n

∑k=1

k

• Parts of the notation• Summand• Index variable• Lower limit• Upper limit

• Sigma notation inline:∑nk=1k

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.7

Page 8: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Generalized Sigma Notation• Specify a condition that the index variable must

satisfy

∑1≤k≤n

k

• Compare:

∑1≤k≤100

k odd

k2

to:

49

∑k=0

(2k +1)2

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.8

Page 9: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Changing the Index Variable• Can always change from one variable to another

∑1≤k≤n

ak =

• What if we want to switch fromk to k +1?Compare:

∑1≤k≤n

ak =

to:

n

∑k=1

ak =

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.9

Page 10: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Zero Terms are OKWhich is better?

n−1

∑i=2

k(k−1)(n− k)

or

n

∑i=0

k(k−1)(n− k)

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.10

Page 11: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Using Iverson Notation• Iverson notation. True-or-false statement

enclosed in brackets. Value is 0 or 1

[p odd] =

• Example

∑1≤k≤100

k odd

k2 = ∑k

k2[1≤ k ≤ 100][k odd]

• 0 in Iverson notation isvery strongly zero

∑k

1k[k > 0]

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.11

Page 12: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Products• Pi notation is similar to Sigma notation

n

∏k=1

k = 1×2×3×·· ·× (n−1)×n

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.12

Page 13: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Working with SummationsDistributive law

∑k∈K

cak = c ∑k∈K

ak

Associative law

∑k∈K

ak +bk = ∑k∈K

ak + ∑k∈K

bk

Commutative law

∑k∈K

ak = ∑p(k)∈K

ak

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.13

Page 14: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Closed Forms for SummationsClosed form is a formula for a summation, with thesummation removed.

∑0≤k≤n

k =n(n+1)

2

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.14

Page 15: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Example

∑0≤k≤n

(a+bk) =

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.15

Page 16: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Perturbation MethodGivenSn = ∑0≤k≤n ak, rewriteSn+1 by splitting offfirst and last term:

Sn +an+1 = a0+ ∑1≤k≤n+1

ak

= a0+ ∑1≤k+1≤n+1

ak+1

= a0+ ∑0≤k≤n

ak+1

Then, work on last sum and express in terms ofSn.

Finally, solve forSn.

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.16

Page 17: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Perturbation Method Example

Sn = ∑0≤k≤n

xk

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.17

Page 18: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Standard Closed FormsArithmetic series

n

∑k=0

k =12

n(n+1)

Sum of squares and cubes

n

∑k=0

k2 =n(n+1)(2n+1)

6n

∑k=0

k3 =n2(n+1)2

4

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.18

Page 19: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Standard Closed FormsGeometric series (x 6= 1)

n

∑k=0

xk =xn+1−1

x−1

Infinite Geometric series (|x| < 1)

∑k=0

xk =1

1− x

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.19

Page 20: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Standard Closed FormsHarmonic series

Hn =n

∑k=0

1k≈ lnn

n 0 1 2 3 4 5 6Hn 0 1 3

2116

2512

13760

4920

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.20

Page 21: Summations (portions from Concrete Mathematics by Graham ...cseweb.ucsd.edu/classes/fa05/cse20/Day12-CSE20.pdf · CSE 20— Nov. 1, 2005, Day 12 Neil Rhodes UC San Diego Summations

Application of Harmonic SeriesGiven a set of 52 playing cards (of length 2 units). Can

you stack them overlapping so the top card completely

overhangs the table?

Summations (portions from Concrete Mathematics by Graham, Knuth, Patashnik) – p.21