+ All Categories
Home > Documents > MA/CS 6a - 2016-17/1term/ma006a/notes/05. Basic Counting.pdf · 10/4/2016 1 Ma/CS 6a Class 5: Basic...

MA/CS 6a - 2016-17/1term/ma006a/notes/05. Basic Counting.pdf · 10/4/2016 1 Ma/CS 6a Class 5: Basic...

Date post: 25-Apr-2018
Category:
Upload: doanthuy
View: 214 times
Download: 1 times
Share this document with a friend
14
10/4/2016 1 Ma/ CS 6 a Class 5: Basic Counting By Adam Sheffer Send anonymous suggestions and complaints from here. Email: [email protected] Password: anonymous2 Only today! 75% off for Morphine and Xanax. Could you open every class by playing Flight of the Valkyries? Why won’t you tell me how to solve the homework?! There aren’t enough crocodiles in the presentations
Transcript

10/4/2016

1

Ma/CS 6aClass 5: Basic Counting

By Adam Sheffer

Send anonymous suggestions and complaints from here.

Email: [email protected]

Password: anonymous2

Only today! 75% off for

Morphine and Xanax.

Could you open every class by

playing Flight of the Valkyries?

Why won’t you tell me how to solve the

homework?!

There aren’t enough crocodiles in the

presentations

10/4/2016

2

Permutations

Problem. Given a set 1,2, … , 𝑛 , in how many ways can we order it?

The case 𝒏 = 𝟑. Six distinct orders / permutations: 123, 132, 213, 231, 312, 321.

The general case.𝑛! = 𝑛 ⋅ 𝑛 − 1 ⋅ ⋯ ⋅ 2 ⋅ 1

Options forplacing 1

Options forplacing 2

Options forplacing 𝑛

Total Number of Subsets

Problem. How many subsets does the set 𝑆 = 1,2, … , 𝑛 have?

◦ Two options for every element 𝑖 ∈ 𝑆. Either 𝑖is in the subset or not.

◦ Since there are 𝑛 element in 𝑆, the number of subsets is 2 ⋅ 2 ⋅ 2 ⋅ … ⋅ 2 = 2𝑛.

10/4/2016

3

Subsets of Size 𝑘

Given a set 1,2, … , 𝑛 , how many (unordered) subsets of size 𝑘 does it have?

Example. Consider the case 𝑛 = 5 and 𝑘 = 3.

◦ The possible subsets are 1,2,3 , 1,2,4 ,1,2,5 , 1,3,4 , 1,3,5 , 1,4,5 , 2,3,4 , 2,3,5 , 2,4,5 , 3,4,5 .

◦ 10 distinct subsets

Subsets of Size 𝑘 (cont.)

Given a set 𝑆 = 1,2,… , 𝑛 , how many (unordered) subsets of size 𝑘 does it have?

Look at the 𝑛! orderings of 𝑆 and consider the first 𝑘 numbers as the subset.

◦ For example, when 𝑛 = 5 and 𝑘 = 3

◦ 12345 34251

◦ 13524 34152

◦ 54321 13542

10/4/2016

4

Binomial Coefficients

Given a set 𝑆 = 1,2,… , 𝑛 , how many (unordered) subsets of size 𝑘 does it have?

Look at the 𝑛! orderings of 𝑆 and consider the first 𝑘 numbers as the subset.

◦ Every subset is obtained 𝑘! 𝑛 − 𝑘 ! times, so

𝑛𝑘

=𝑛!

𝑘! 𝑛 − 𝑘 !

Pronounced“𝑛 choose 𝑘”

Warm-up Problem

Prove or disprove. For every 𝑛 ≥ 𝑘 ≥ 0

𝑛𝑘

=𝑛

𝑛 − 𝑘.

True. Deciding which 𝑘 elements to choose is like deciding which 𝑛 − 𝑘elements not to take.

10/4/2016

5

Pascal’s Rule

Prove. For every 𝑛 ≥ 𝑘 ≥ 0

𝑛𝑘

=𝑛 − 1𝑘 − 1

+𝑛 − 1𝑘

.

# of subsetscontaining 1

# of subsets notcontaining 1

Pascal’s Triangle

Pascal’s rule:𝑛𝑘

=𝑛 − 1𝑘 − 1

+𝑛 − 1𝑘

.

𝑛𝑘

is element 𝑘 + 1 of row 𝑛 + 1.

Every number is the sum of the two numbers above it.

10/4/2016

6

A Sum of Binomial Coefficients

Prove. For every 𝑛 ≥ 𝑘 ≥ 0

𝑛0

+𝑛1

+𝑛2

+⋯+𝑛𝑛

= 2𝑛.

The left-hand side is the number of subsets of 1,2,3, … , 𝑛 , which is 2𝑛.

Partitioning into 𝑘 Subsets

Problem. For 𝑛, 𝑘 > 0, we have 𝑛identical balls and 𝑘 bins. In how many ways can we place the balls in the bins?

Example. If we have three balls and two bins, there are four options: (3,0), (2,1), (1,2), (0,3).

10/4/2016

7

Partitioning into 𝑘 Subsets

Problem. For 𝑛, 𝑘 > 0, we have 𝑛identical balls and 𝑘 bins. In how many ways can we place the balls in the bins?

Answer.𝑛 + 𝑘 − 1𝑘 − 1

. The 𝑘 − 1 choices

correspond to the end of each bin.

x x x x x

Bin #1:1 ball

Bin #2:3 balls

Bin #4:empty

The Binomial Theorem

Recall.

◦ 𝑥 + 𝑦 2 = 𝑥2 + 2𝑥𝑦 + 𝑦2.

◦ 𝑥 + 𝑦 3 = 𝑥3 + 3𝑥2𝑦 + 3𝑥𝑦2 + 𝑦3.

The binomial theorem. What is 𝑥 + 𝑦 𝑛?

0≤𝑖,𝑗≤𝑛𝑖+𝑗=𝑛

𝑛𝑖𝑥𝑖 𝑦𝑗

=𝑛0

𝑥𝑛 +𝑛1

𝑥𝑛−1𝑦 +𝑛2

𝑥𝑛−2𝑦2 +⋯

10/4/2016

8

The Binomial Theorem – Proof

The binomial theorem.

𝑥 + 𝑦 𝑛 =

0≤𝑖≤𝑛

𝑛𝑖𝑥𝑖 𝑦𝑛−𝑖 .

Proof. We have 𝑥 + 𝑦 𝑛 = 𝑥 + 𝑦 𝑥 + 𝑦 ⋯ 𝑥 + 𝑦 .

The coefficient of 𝑥𝑖𝑦𝑛−𝑖 is the number of ways to choose 𝑥 from 𝑖 of the parentheses and 𝑦from the remaining ones.

That is, the coefficient of 𝑥𝑖𝑦𝑛−𝑖 is 𝑛𝑖

.

The Binomial Theorem and Pascal’s Triangle

𝑥 + 𝑦 1 = 𝑥 + 𝑦𝑥 + 𝑦 2 = 𝑥2 + 2𝑥𝑦 + 𝑦2

𝑥 + 𝑦 3 = 𝑥3 + 3𝑥2𝑦 + 3𝑥𝑦2 + 𝑦3

𝑥 + 𝑦 4 = 𝑥4 + 4𝑥3𝑦 + 6𝑥2𝑦2 + 4𝑥𝑦3 + 𝑦4

10/4/2016

9

Monomials and Degrees

Polynomials are sums of monomials:

𝑥7 + 3𝑥2𝑦4𝑧 + 5𝑥3𝑧3 +⋯

The degree of a monomial is the sum of the powers of its variables.

deg 3𝑥2𝑦4𝑧 = 2 + 4 + 1 = 7 .

The degree of a polynomial is the maximum of the degrees of its monomials

deg 𝑥5 + 3𝑥2𝑦4𝑧 + 5𝑥3𝑧3 = 7

Number of Monomials

Problem. How many distinct monomials can a polynomial of degree 𝐷 in 𝑘variables have?

Answer. Take 𝑘 + 1 bins – one for every variable and one extra. Every placement of 𝐷 balls in the bins corresponds to a monomial.

1x2x

kx 1

...

...𝑥14𝑥2𝑥𝑘

10/4/2016

10

Number of Monomials

Problem. How many distinct monomials can a polynomial of degree 𝐷 in 𝑘variables have?

Answer. Take 𝑘 + 1 bins – one for every variable and one extra. Every placement of 𝐷 balls in the bins corresponds to a monomial.

𝐷 + 𝑘𝑘

Returning to Lecture 3

To prove Fermat’s little theorem we assumed, without proof, that for any prime 𝑝

𝑎 + 𝑏 𝑝 ≡ 𝑎𝑝 + 𝑏𝑝 𝑚𝑜𝑑 𝑝.

Proof. By the binomial theorem:

𝑎 + 𝑏 𝑝 =𝑝0

𝑎𝑝 +𝑝1

𝑎𝑝−1𝑏 +𝑝2

𝑎𝑝−2𝑏2 +⋯

To prove the claim, it suffices to prove that

𝑝|𝑝𝑖

for every 1 ≤ 𝑖 ≤ 𝑝 − 1.

This holds since in 𝑝𝑖

=𝑝!

𝑖! 𝑝−𝑖 !the numerator

is divisible by 𝑝 but the denominator is not.

10/4/2016

11

Partitions of an Integer

𝑟, 𝑛 – two positive integers.

Problem. What is the number of solutions of

𝑎1 + 𝑎2 +⋯+ 𝑎𝑟 = 𝑛,

where each 𝑎𝑖 is a natural number?

5 = 1 + 1 + 3 = 1 + 3 + 1 = 0 + 0 + 5= 1 + 0 + 4 = ⋯

Solution

Consider 𝑛 as a sum of 𝑛 unit elements.

Dividing these elements across the 𝑟variables 𝑎𝑖 is equivalent to placing 𝑛balls in 𝑟 bins.

◦ The value of 𝑎𝑖 is the number of balls in the 𝑖’th bin.

𝑛 + 𝑟 − 1𝑟 − 1

10/4/2016

12

Another Inequality

Problem. Prove the identity𝑛0

2+

𝑛1

2+

𝑛2

2+⋯+

𝑛𝑛

2=

2𝑛𝑛

.

Proof.

◦ We begin with the identity1 + 𝑥 𝑛 1 + 𝑥 𝑛 = 1 + 𝑥 2𝑛.

◦ By the binomial theorem, we have𝑛0

+𝑛1

𝑥 +⋯+𝑛𝑛

𝑥𝑛 ൬𝑛0

+𝑛1

𝑥 +⋯

Proof (cont.)

𝑛0

+𝑛1

𝑥 +⋯+𝑛𝑛

𝑥𝑛 ൬𝑛0

+𝑛1

𝑥 +⋯

10/4/2016

13

Summing Up

In how many ways can we choose 𝑘elements from 1,2,3, … , 𝑛 ?

Ordered Unordered

No repetitions 𝑛!

(𝑛 − 𝑘)!

𝑛𝑘

With repetitions 𝑛𝑘 𝑘 + 𝑛 − 1𝑛 − 1

Summing Up #2

In how many ways can we place 𝑘 balls into 𝑛 bins?

At most 1 ball in each bin

Any number of balls in each bin

Each ball has a different color

𝑛!

𝑛 − 𝑘 !

𝑛𝑘

Balls are indistinguishable

𝑛𝑘

𝑘 + 𝑛 − 1𝑛 − 1

10/4/2016

14

The End


Recommended