Classic P.I.E.

## 2916023

https://math.stackexchange.com/questions/2916023

**Determine the number of positive integers LE than 100 not divisible by 2,3 or 5.**

In Goulden-Jackson approach, the PIE looks like :

N
(
x
# )
E
(
x
1
)

{\displaystyle N(x)=E(x+1)}

For the considered example we will obtain the "exact generating function"

E
(
x
# )
26
48
x
32

x
2

3

x
3

{\displaystyle E(x) = 26 + 48x + 32x^2 + 3x^3}

since we have 26 numbers that are not divisible with 2 or 3 or 5, 48 numbers that are divisible with **exactly** one of {2,3, 5}, 32 numbers divisible with **exactly** two of them and three numbers divisible with 2 and 3 and 5.

N
(
x
# )
100
103
x
32

x
2

3

x
3

{\displaystyle N(x) = 100 + 103x + 32x^2 + 3x^3}

is the "at least" generating function for numbers that are divisible with **at least** zero, one, two or three of {2,3,5}

We have to obtain the 26 knowing 100, 103 = 50 + 33 + 20, 32 = 16 + 6 + 10 and 3

Well, by Goulden-Jackson,

# 26
E
(
0
# )
N
(
−
1
# )
100
−
103
32
−
3

{\displaystyle 26 = E(0) = N(-1) = 100-103+32-3}

One may see that the binomial coefficients occur in

E
(
x
1
)

{\displaystyle E(x+1)}

.

### **Species Formula**

N
(
X
,
Y
,
Z
# )
100
50
[
X
]
33
[
Y
]
20
[
Z
]
16
[
X
,
Y
]
10
[
Y
,
Z
]
6
[
Y
,
Z
]
3
[
X
,
Y
,
Z
]

{\displaystyle N(X,Y,Z) = 100 + 50[X] + 33[Y] + 20[Z] + 16[X,Y] + 10 [Y,Z] + 6[Y,Z] + 3[X,Y,Z]}

## 2965288

https://math.stackexchange.com/questions/2965288

Inclusion\_exclusion general formula for intersections?

⋂
i

A
i

=

∑

i

A
i

−

∑

i
<
j

A
i

⋃

A
j

∑

i
<
j
<
k

A
i

⋃

A
j

⋃

A
k

−
…

every element that belongs to all

A
1

.
.
.

A
n

{\displaystyle A\_1...A\_n}

 may be found exactly once in the left intersection.
In the right-hand part it is counted multiple times, like :

n

t
i
m
e
s
−

(

n
2

)

t
i
m
e
s

(

n
3

)

t
i
m
e
# ⋯
1

t
i
m
e

{\displaystyle n\ times - \binom n 2 \ times + \binom n 3 \ times =\cdots = 1 \ time }

 because

(
1
−
1

)
n

=
0

{\displaystyle (1-1)^n = 0}

.

Overall, every element in intersection is counted exactly one time so we get the size of the intersection.

## 3916900

https://math.stackexchange.com/questions/3916900

Suppose we have a deck of cards with cards of each of the four suits. In how ways we can choose six cards such that there are cards of exactly three different suits among the chosen cards?

There are four qualities that hands may have. There are hands that miss clubs, hands that have no hearts, hands without spades and hands without diamonds.

The situation is tricky because the binomial coefficients intervene in a double way. To reveal this let us use $N(x)$ and $E(x)$ the generating functions for the "hands having at least x qualities" and "hands having exactly x qualities".

Shortly, P.I.E says that $N(x)= E(x+1)$

Here

$N(x) = \binom 4 3 \binom 8 6 x^3 + \binom 4 2 \binom {16} 6 x^2 + \binom 4 1 \binom {24} 6x + \binom 4 0 \binom {32} 6$

$N(x) =112x^3 + 48048x^2 + 538384x + 906192$

$E(x) = N(x-1) = 12x^3 + 47712x^2 + 442624x + 415744$

As one may see, $442624$, the desired number, is

$442664 = \color {red}{\binom 3 1 }\binom 4 3 \binom 8 6 - \color{red}{\binom 2 1 } \binom 4 2 \binom {16} 6 + \color{red}{\binom 1 1 } \binom 4 1 \binom {24} 6$

Suppose now we have a 3-color deck of 24 cards and we are interested in all-color hands. Again,

$N(x) = \binom 3 2 \binom 8 6 x^2 + \binom 3 1 \binom {16} 6 x + \binom 3 0 \binom {24} 6 $

$N(x) =84x^2 + 24024x + 134596$

$E(x) = N(x-1) = 84x^2 + 23846x + 110656$

$110656 = \color {red}{\binom 2 0 }\binom 3 2 \binom 8 6 - \color{red}{\binom 1 0 } \binom 3 1 \binom {16} 6 + \color{red}{\binom 0 0 } \binom 3 0 \binom {24} 6$

Again, as we may see, $442624 = 4\times 110656$