Counting iii pascal s triangle polynomials and vector programs
This presentation is the property of its rightful owner.
Sponsored Links
1 / 105

Counting III: Pascal’s Triangle, Polynomials, and Vector Programs PowerPoint PPT Presentation


  • 127 Views
  • Uploaded on
  • Presentation posted in: General

X 1. X 2. +. +. X 3. Counting III: Pascal’s Triangle, Polynomials, and Vector Programs. X n+1 - 1. 1 + X 1 + X 2 + X 3 + … + X n-1 + X n =. X - 1. The Geometric Series. 1. 1 + X 1 + X 2 + X 3 + … + X n + ….. =. 1 - X. The Infinite Geometric Series. 1.

Download Presentation

Counting III: Pascal’s Triangle, Polynomials, and Vector Programs

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Counting iii pascal s triangle polynomials and vector programs

  • X1

  • X2

  • +

  • +

  • X3

Counting III: Pascal’s Triangle, Polynomials, and Vector Programs


The geometric series

Xn+1 - 1

1 + X1 + X2 + X 3 + … + Xn-1 + Xn =

X- 1

The Geometric Series


The infinite geometric series

1

1 + X1 + X2 + X 3 + … + Xn + ….. =

1 - X

The Infinite Geometric Series


Counting iii pascal s triangle polynomials and vector programs

1

1 + X1 + X2 + X 3 + … + Xn + ….. =

1 - X

  • (X-1) ( 1 + X1 + X2 + X 3 + … + Xn + … )

  • = X1 + X2 + X 3 + … + Xn + Xn+1 + ….

  • - 1 - X1 - X2 - X 3 - … - Xn-1 – Xn - Xn+1 - …

  • = 1


Counting iii pascal s triangle polynomials and vector programs

1

1 + X1 + X2 + X 3 + … + Xn + ….. =

1 - X

  • 1 + x + …..

  • ____________________

  • 1-x | 1

  • -[1 – x]

  • _____

  • x

  • -[x – x2 ]

  • ______

  • x2

  • -....


Geometric series linear form

Geometric Series (Linear Form)

1

1 + aX1 + a2X2 + a3X 3 + … + anXn + ….. =

1 - aX


Geometric series quadratic form

Geometric Series (Quadratic Form)

(1 + aX1 + a2X2 + … + anXn + …..) (1 + bX1 + b2X2 + … + bnXn + …..) =

1

(1 – aX)(1-bX)


Suppose we multiply this out to get a single infinite polynomial what is an expression for c n

Suppose we multiply this out to get a single, infinite polynomial.What is an expression for Cn?

(1 + aX1 + a2X2 + … + anXn + …..) (1 + bX1 + b2X2 + … + bnXn + …..) =

1 + c1X1 + .. + ck Xk + …


C n a 0 b n a 1 b n 1 a i b n i a n 1 b 1 a n b 0

cn =a0bn + a1bn-1 +… aibn-i… + an-1b1 + anb0

(1 + aX1 + a2X2 + … + anXn + …..) (1 + bX1 + b2X2 + … + bnXn + …..) =

1 + c1X1 + .. + ck Xk + …


If a b then c n n 1 a n a 0 b n a 1 b n 1 a i b n i a n 1 b 1 a n b 0

If a = b then cn = (n+1)(an)a0bn + a1bn-1 +… aibn-i… + an-1b1 + anb0

(1 + aX1 + a2X2 + … + anXn + …..) (1 + bX1 + b2X2 + … + bnXn + …..) =

1 + c1X1 + .. + ck Xk + …


Counting iii pascal s triangle polynomials and vector programs

an+1 – bn+1

a- b

a0bn + a1bn-1 +… aibn-i… + an-1b1 + anb0 =

  • (a-b) (a0bn + a1bn-1 +… aibn-i… + an-1b1 + anb0)

  • = a1bn +… ai+1bn-i… + anb1 + an+1b0

  • - a0bn+1 – a1bn… ai+1bn-i… - an-1b2 - anb1

  • = - bn+1 + an+1

  • = an+1 – bn+1


If a b then c n a 0 b n a 1 b n 1 a i b n i a n 1 b 1 a n b 0

an+1 – bn+1

a- b

if a  b then cn =a0bn + a1bn-1 +… aibn-i… + an-1b1 + anb0

(1 + aX1 + a2X2 + … + anXn + …..) (1 + bX1 + b2X2 + … + bnXn + …..) =

1 + c1X1 + .. + ck Xk + …


Geometric series quadratic form1

an+1 – bn+1

a- b

Geometric Series (Quadratic Form)

(1 + aX1 + a2X2 + … + anXn + …..) (1 + bX1 + b2X2 + … + bnXn + …..) =

1

=

(1 – aX)(1-bX)

n=0..1

Xn

=

n=0..1

or

Xn

(n+1)an

when a=b


Counting iii pascal s triangle polynomials and vector programs

Previously, we saw that

Polynomials Count!


Counting iii pascal s triangle polynomials and vector programs

What is the coefficient of BA3N2 in the expansion of

(B + A + N)6?

The number of ways to rearrange the letters in the word BANANA.


Choice tree for terms of 1 x 3

1

1

1

1

X

X

X

X

1

X

1

X

1

X

Choice tree for terms of (1+X)3

X2

X2

X3

X

X

X2

X

1

Combine like terms to get 1 + 3X + 3X2 + X3


The binomial formula

The Binomial Formula

Binomial Coefficients

binomial expression


The binomial formula1

The Binomial Formula


One polynomial two representations

One polynomial, two representations

“Product form” or

“Generating form”

“Additive form” or

“Expanded form”


Power series representation

Power Series Representation

“Closed form” or

“Generating form”

“Power series” (“Taylor series”) expansion


Counting iii pascal s triangle polynomials and vector programs

Let x=1.

The number of

subsets of an

n-element set

By playing these two representations against

each other we obtain a new representation of

a previous insight:


Counting iii pascal s triangle polynomials and vector programs

By varying x, we can discover new identities

Let x= -1.

Equivalently,


Counting iii pascal s triangle polynomials and vector programs

The number of even-sized subsets of an n element set is the same as the number of odd-sized subsets.

Let x= -1.

Equivalently,


Counting iii pascal s triangle polynomials and vector programs

We could discover new identities by substituting in different numbers for X. One cool idea is to try complex roots of unity, however, the lecture is going in another direction.


Counting iii pascal s triangle polynomials and vector programs

Proofs that work by manipulating algebraic forms are called “algebraic” arguments.Proofs that build a 1-1 onto correspondence are called “combinatorial” arguments.


Counting iii pascal s triangle polynomials and vector programs

Let On be the set of binary strings of length n with an odd number of ones.

Let En be the set of binary strings of length n with an even number of ones.

We gave an algebraic proof that

On =  En


A combinatorial proof

A Combinatorial Proof

Let On be the set of binary strings of length n with an odd number of ones.

Let En be the set of binary strings of length n with an even number of ones.

A combinatorial proof must construct a one-to-one correspondence betweenOn and En


An attempt at a correspondence

An attempt at a correspondence

Let fn be the function that takes an

n-bit string and flips all its bits.

...but do even n work? In f6 we have

110011  001100

101010  010101

Uh oh. Complementing maps evens to evens!

fn is clearly a one-to-one and onto function

for odd n. E.g. in f7 we have

0010011  1101100

1001101  0110010


A correspondence that works for all n

A correspondence that works for all n

Let fn be the function that takes an

n-bit string and flips only the first bit.

For example,

0010011  1010011

1001101  0001101

110011  010011

101010  001010


Counting iii pascal s triangle polynomials and vector programs

The binomial coefficients have so many representations that many fundamental mathematical identities emerge…


The binomial formula2

The Binomial Formula

1

(1+X)0 =

1 + 1X

(1+X)1 =

1 + 2X + 1X2

(1+X)2 =

1 + 3X + 3X2 + 1X3

(1+X)3 =

1 + 4X + 6X2 + 4X3 + 1X4

(1+X)4 =


Pascal s triangle k th row are the coefficients of 1 x k

Pascal’s Triangle:kth row are the coefficients of (1+X)k

1

(1+X)0 =

1 + 1X

(1+X)1 =

1 + 2X + 1X2

(1+X)2 =

1 + 3X + 3X2 + 1X3

(1+X)3 =

1 + 4X + 6X2 + 4X3 + 1X4

(1+X)4 =


K th row of pascal s triangle

kth Row Of Pascal’s Triangle:

1

(1+X)0 =

1 + 1X

(1+X)1 =

1 + 2X + 1X2

(1+X)2 =

1 + 3X + 3X2 + 1X3

(1+X)3 =

1 + 4X + 6X2 + 4X3 + 1X4

(1+X)4 =


Counting iii pascal s triangle polynomials and vector programs

Inductive definition of kth entry of nth row:Pascal(n,0) = Pacal (n,n) = 1; Pascal(n,k) = Pascal(n-1,k-1) + Pascal(n,k)

1

(1+X)0 =

1 + 1X

(1+X)1 =

1 + 2X + 1X2

(1+X)2 =

1 + 3X + 3X2 + 1X3

(1+X)3 =

1 + 4X + 6X2 + 4X3 + 1X4

(1+X)4 =


Counting iii pascal s triangle polynomials and vector programs

“Pascal’s Triangle”

Al-Karaji, Baghdad 953-1029

Chu Shin-Chieh 1303The Precious Mirror of the Four Elements

. . . Known in Europe by 1529

Blaise Pascal 1654


Pascal s triangle

Pascal’s Triangle

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1

“It is extraordinary

how fertile in

properties the

triangle is.

Everyone can

try his

hand.”


Counting iii pascal s triangle polynomials and vector programs

Summing The Rows

1

1 + 1

1 + 2 + 1

1 + 3 + 3 + 1

1 + 4 + 6 + 4 + 1

1 + 5 + 10 + 10 + 5 + 1

1 + 6 + 15 + 20 + 15 + 6 + 1

=1

=2

=4

=8

=16

=32

=64


Counting iii pascal s triangle polynomials and vector programs

6+20+6

=

1+15+15+1

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1


Counting iii pascal s triangle polynomials and vector programs

Summing on 1st Avenue

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1


Counting iii pascal s triangle polynomials and vector programs

Summing on kth Avenue

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1


Counting iii pascal s triangle polynomials and vector programs

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1

=2

=3

=5

=8

=13


Counting iii pascal s triangle polynomials and vector programs

1

1 1

1 2 1

1 3 3 1

1 4 6 4 1

1 5 10 10 5 1

1 6 15 20 15 6 1

2

2

2

2

2

2

2


Counting iii pascal s triangle polynomials and vector programs

Al-Karaji Squares

1

1 1

1 2 +2*1

1 3 +2*3 1

1 4 +2*6 4 1

1 5 +2*10 10 5 1

1 6 +2*15 20 15 6 1

=0

=1

=4

=9

=16

=25

=36


Counting iii pascal s triangle polynomials and vector programs

All these properties can be proved inductively and algebraically. We will give combinatorial proofs using the Manhattan block walking representation of binomial coefficients.


How many shortest routes from a to b

How many shortest routes from A to B?

A

B


Manhattan

0

0

j’th Street

k’th Avenue

1

1

2

2

3

3

4

4

Manhattan


Manhattan1

Level n

0

2

4

3

1

0

k’th Avenue

………

1

………….

2

……………………

3

…………………………

4

…………………………………

Manhattan


Manhattan2

Level n

0

2

4

3

1

0

k’th Avenue

………

1

………….

2

……………………

3

…………………………

4

…………………………………

Manhattan


Counting iii pascal s triangle polynomials and vector programs

. . . . .

k’th Avenue

1

. . . . .

level n

1

1

. . . . .

2

1

1

. . . . .

3

3

1

1

. . . . .

4

1

6

1

4

1

1

5

5

10

10

6

6

15

15

20


Counting iii pascal s triangle polynomials and vector programs

. . . . .

k’th Avenue

1

. . . . .

level n

1

1

. . . . .

2

1

1

. . . . .

3

3

1

1

. . . . .

4

1

6

1

4

1

1

5

5

10

10

6

6

15

15

20


Counting iii pascal s triangle polynomials and vector programs

. . . . .

k’th Avenue

1

. . . . .

level n

1

1

. . . . .

2

1

1

. . . . .

3

3

1

1

. . . . .

4

1

6

1

4

1

1

5

5

10

10

6

6

15

15

20


Counting iii pascal s triangle polynomials and vector programs

. . . . .

k’th Avenue

1

. . . . .

level n

1

1

. . . . .

2

1

1

. . . . .

3

3

1

1

. . . . .

4

1

6

1

4

1

1

5

5

10

10

6

6

15

15

20


Counting iii pascal s triangle polynomials and vector programs

By convention:

(empty product = 1)


Counting iii pascal s triangle polynomials and vector programs

. . . . .

k’th Avenue

1

. . . . .

level n

1

1

. . . . .

2

1

1

. . . . .

3

3

1

1

. . . . .

4

1

6

1

4

1

1

5

5

10

10

6

6

15

15

20


Counting iii pascal s triangle polynomials and vector programs

Application (Al-Karaji):


Vector programs

Vector Programs

  • Let’s define a (parallel) programming language called VECTOR that operates on possibly infinite vectors of numbers. Each variable V! can be thought of as:

  • < * , * , * , * , *, *, . . . . . . . . . >

  • 0 1 2 3 4 5 . . . . . . . . .


Vector programs1

Vector Programs

  • Let k stand for a scalar constant

  • <k> will stand for the vector <k,0,0,0,…>

  • <0> = <0,0,0,0,….>

  • <1> = <1,0,0,0,…>

  • V! +T!means to add the vectors position-wise.

  • <4,2,3,…> + <5,1,1,….> = <9,3,4,…>


Vector programs2

Vector Programs

  • RIGHT(V!) means to shift every number in V! one position to the right and to place a 0 in position 0.

  • RIGHT( <1,2,3, …> ) = <0,1,2,3,. …>


Vector programs3

Vector Programs

  • Stare

  • V! = <6,0,0,0,..>

  • V! = <42,6,0,0,..>

  • V! = <2,42,6,0,..> V!= <13,2,42,6,.>

  • Example:

  • V! := <6>;

  • V! := RIGHT(V!)+ <42>;

  • V! := RIGHT(V!)+ <2>;

  • V! := RIGHT(V!)+ <13>;

V! = < 13, 2, 42, 6, 0, 0, 0, . . . >


Vector programs4

Vector Programs

  • Stare

  • V! = <1,0,0,0,..>

  • V! = <1,1,0,0,..>

  • V! = <1,2,1,0,..> V! = <1,3,3,1,.>

  • Example:

  • V! := <1>;

  • Loop n times:

  • V! := V! +RIGHT(V!);

V! = nth row of Pascal’s triangle.


Counting iii pascal s triangle polynomials and vector programs

Vector programs can be implemented by polynomials!

  • X1

  • X2

  • +

  • +

  • X3


Programs polynomials

Programs -----> Polynomials

  • The vector V! = < a0, a1, a2, . . . > will be represented by the polynomial:


Formal power series

Formal Power Series

  • The vector V! = < a0, a1, a2, . . . > will be represented by the formal power series:


V a 0 a 1 a 2

V! = < a0, a1, a2, . . . >

<0>is represented by 0

<k>is represented by k

V! + T! is represented by (PV + PT)

RIGHT(V! ) is represented by (PV X)


Vector programs5

Vector Programs

  • Example:

  • V! := <1>;

  • Loop n times:

  • V! := V! +RIGHT(V!);

PV := 1;

PV := PV + PV X;

V! = nth row of Pascal’s triangle.


Vector programs6

Vector Programs

  • Example:

  • V! := <1>;

  • Loop n times:

  • V! := V! +RIGHT(V!);

PV := 1;

PV := PV (1+ X);

V! = nth row of Pascal’s triangle.


Vector programs7

Vector Programs

  • Example:

  • V! := <1>;

  • Loop n times:

  • V! := V! +RIGHT(V!);

PV = (1+ X)n

V! = nth row of Pascal’s triangle.


Counting iii pascal s triangle polynomials and vector programs

What is the coefficient of Xk in the expansion of:

( 1 + X + X2 + X3 + X4 + . . . . )n ?

Each path in the choice tree for the cross terms has n choices of exponent e1, e2, . . . , en ¸ 0. Each exponent can be any natural number.

Coefficient of Xk is the number of non-negative solutions to: e1 + e2 + . . . + en = k


Counting iii pascal s triangle polynomials and vector programs

What is the coefficient of Xk in the expansion of:

( 1 + X + X2 + X3 + X4 + . . . . )n ?


Counting iii pascal s triangle polynomials and vector programs

( 1 + X + X2 + X3 + X4 + . . . . )n =


Counting iii pascal s triangle polynomials and vector programs

What is the coefficient of Xk in the expansion of:

(a0 + a1X + a2X2 + a3X3 + …) ( 1 + X + X2 + X3 + . . . )

= (a0 + a1X + a2X2 + a3X3 + …) / (1 – X) ?

a0 + a1 + a2 + .. + ak


Counting iii pascal s triangle polynomials and vector programs

(a0 + a1X + a2X2 + a3X3 + …) / (1 – X)

=

=

PREFIXSUM(a0 + a1X + a2X2 + a3X3 + …)


Counting iii pascal s triangle polynomials and vector programs

Let’s add an instruction called PREFIXSUM to our VECTOR language.

W! := PREFIXSUM(V!)

means that the ith position of W contains the sum of all the numbers in V from positions 0 to i.


What does this program output

0

k’th Avenue

1

2

3

4

What does this program output?

  • V! := 1! ;

  • Loop k times: V! := PREFIXSUM(V!) ;


Counting iii pascal s triangle polynomials and vector programs

Can you see how PREFIXSUM can be represented by a familiar polynomial expression?


Counting iii pascal s triangle polynomials and vector programs

W! := PREFIXSUM(V!)

is represented by

PW = PV / (1-X)

= PV (1+X+X2+X3+ ….. )


Al karaji program

Al-Karaji Program

  • Zero_Ave := PREFIXSUM(<1>);

  • First_Ave := PREFIXSUM(Zero_Ave);

  • Second_Ave :=PREFIXSUM(First_Ave);

  • Output:= First_Ave + 2*RIGHT(Second_Ave)

OUTPUT! = <1, 4, 9, 25, 36, 49, …. >


Al karaji program1

Al-Karaji Program

  • Zero_Ave = 1/(1-X);

  • First_Ave = 1/(1-X)2;

  • Second_Ave = 1/(1-X)3;

  • Output = 1/(1-X)2 + 2X/(1-X)3

(1-X)/(1-X)3 + 2X/(1-X)3

= (1+X)/(1-X)3


1 x 1 x 3

(1+X)/(1-X)3

  • Zero_Ave := PREFIXSUM(<1>);

  • First_Ave := PREFIXSUM(Zero_Ave);

  • Second_Ave :=PREFIXSUM(First_Ave);

  • Output:= RIGHT(Second_Ave) + Second_Ave

Second_Ave = <1, 3, 6, 10, 15,.

RIGHT(Second_Ave) = <0, 1, 3, 6, 10,.

Output = <1, 4, 9, 16, 25


Counting iii pascal s triangle polynomials and vector programs

(1+X)/(1-X)3

outputs <1, 4, 9, ..>

X(1+X)/(1-X)3

outputs <0, 1, 4, 9, ..>

The kth entry is k2


Counting iii pascal s triangle polynomials and vector programs

X(1+X)/(1-X)3 =  k2Xk

What does X(1+X)/(1-X)4 do?


Counting iii pascal s triangle polynomials and vector programs

X(1+X)/(1-X)4 expands to :

 Sk Xk

where Sk is the sum of the first k squares


Counting iii pascal s triangle polynomials and vector programs

Aha! Thus, if there is an alternative interpretation of the kth coefficient of X(1+X)/(1-X)4we would have a new way to get a formula for the sum of the first k squares.


Counting iii pascal s triangle polynomials and vector programs

Using pirates and gold we found that:

THUS:


Coefficient of x k in p v x 2 x 1 x 4 is the sum of the first k squares

Coefficient of Xk in PV = (X2+X)(1-X)-4 is the sum of the first k squares:


Vector programs polynomials closed form expression

Vector programs -> Polynomials-> Closed form expression


Counting iii pascal s triangle polynomials and vector programs

Expressions of the form

Finite Polynomial / Finite Polynomial

are called Rational Polynomial Expressions.

Clearly, these expressions have some deeper interpretation as a programming language.


Counting iii pascal s triangle polynomials and vector programs

What about this one?

X/(1-X-X2)


Counting iii pascal s triangle polynomials and vector programs

The action of dividing one polynomial by another can simulate a program to recursively compute Fibonacci numbers.


Vector program i o

Vector Program I/O

  • Example:

  • INPUT I!; /* not allowed to alter I! */

  • V! := I! + 1;

  • Loop n times:

  • V! := V! +RIGHT(V!) + I! ;

  • OUTPUT V!


Vector recurrence relations

Vector Recurrence Relations

  • Let P be a vector program that takes input.

  • A vector relation is any statement of the form:

  • V! = P( V! )

  • If there is a unique V! satisfying the relation, then V! is said to be defined by the relation V! = P( V! ).


Fibonacci numbers

Vector Recurrence Relation Definition:

F! = RIGHT( F! + <1> ) + RIGHT( RIGHT( F! ) )

Fibonacci Numbers

Recurrence Relation Definition:


Counting iii pascal s triangle polynomials and vector programs

F! = RIGHT( F! + <1> ) + RIGHT( RIGHT( F! ) )

F! = a0, a1 , a2, a3, a4, . . .

RIGHT(F! +<1>) = 0, a0 + 1, a1, a2, a3,

RIGHT( RIGHT( F! ) )

= 0, 0 , a0, a1, a2, a3, .


Counting iii pascal s triangle polynomials and vector programs

F! = RIGHT( F! + 1 ) + RIGHT( RIGHT( F! ) )

F = a0 + a1 X + a2 X2 + a3 X3 +

RIGHT(F + 1) = (F+1)X

RIGHT( RIGHT( F ) )

= FX2


Counting iii pascal s triangle polynomials and vector programs

F = (F + 1) X + F X2

F = a0 + a1 X + a2 X2 + a3 X3 + . . .

RIGHT(F + 1) = (F+1)X

RIGHT( RIGHT( F ) )

= F X2


Counting iii pascal s triangle polynomials and vector programs

F = F X + X + F X2

Solve for F.

F - FX - FX2 = X

F(1-X-X2) = XF = X/(1-X-X2)


Counting iii pascal s triangle polynomials and vector programs

What is the Power Series Expansion of x / (1-x-x2) ?


Counting iii pascal s triangle polynomials and vector programs

Since the bottom is quadratic we can factor it.

X / (1-X-X2) =

X/(1- X)(1 – (-)-1X)

where  =

“The Golden Ratio”


Linear factors on the bottom

Linear factors on the bottom

X

(1 – X)(1- (--1X)

?

n=0..∞

Xn

=


Geometric series quadratic form2

an+1 – bn+1

a- b

Geometric Series (Quadratic Form)

(1 + aX1 + a2X2 + … + anXn + …..) (1 + bX1 + b2X2 + … + bnXn + …..) =

1

=

(1 – aX)(1-bX)

n=0..1

Xn

=


Geometric series quadratic form3

n+1 – (--1)n+1

5

Geometric Series (Quadratic Form)

1

(1 – X)(1- (--1X)

n=0.. ∞

Xn

=


Power series expansion of f

n+1 – (--1)n+1

5

Power Series Expansion of F

X

(1 – X)(1- (--1X)

n=0.. ∞

Xn+1

=


Counting iii pascal s triangle polynomials and vector programs

The ith Fibonacci number is:


References

References

  • Applied Combinatorics, by Alan Tucker

  • Generatingfunctionology, Herbert Wilf


  • Login