0% found this document useful (0 votes)
263 views43 pages

Euler's Phi Function

The document discusses Euler's phi function φ(n) and its properties. It begins by defining φ(n) as the number of positive integers less than or equal to n that are relatively prime to n. It notes that φ(n) is difficult to compute without knowing the prime factorization of n, and is related to the security of cryptographic systems like RSA. It then provides the formula for φ(n) in terms of the prime factorization of n, and proves this formula using the principle of inclusion and exclusion. It also shows that φ(n) is multiplicative.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
263 views43 pages

Euler's Phi Function

The document discusses Euler's phi function φ(n) and its properties. It begins by defining φ(n) as the number of positive integers less than or equal to n that are relatively prime to n. It notes that φ(n) is difficult to compute without knowing the prime factorization of n, and is related to the security of cryptographic systems like RSA. It then provides the formula for φ(n) in terms of the prime factorization of n, and proves this formula using the principle of inclusion and exclusion. It also shows that φ(n) is multiplicative.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 43

Euler’s Phi Function

• Let φ(n) denote the number of positive integers


m ∈ { 1, 2, . . . , n } such that gcd(m, n) = 1, where n ≥ 2.
– φ(p) = p − 1 for prime p.
– φ(1) = 1 by convention.
• It is a computationally hard problem without the
knowledge of n’s factorization.
– Related to the security of some cryptographical
systems such as RSA.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 421
Euler’s Phi Function: The Formula
Theorem 61 Let n = pe11 pe22 · · · pet t be the prime
factorization of n. Then
t  
1
φ(n) = n 1− .
i=1
p i

• Let ci be the condition that a number from { 1, 2, . . . , n }


is divisible by pi .
• The desired number is
φ(n) = N (c1 c2 · · · ct ).

• For distinct i1 , i2 , . . . , ik ,
n
N (ci1 ci2 · · · cik ) = .
pi1 pi2 · · · pik

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 422
The Proof (concluded)
• By the principle of inclusion and exclusion,

φ(n)
= N (c1 c2 · · · ct )
t
 
k n
= (−1)
pi1 pi2 · · · pik
k=0 1≤i1 <···<ik ≤t
t
 
k 1
= n (−1)
pi1 pi2 · · · pik
k=0 1≤i1 <···<ik ≤t
t 
 
1
= n 1− . (51)
i=1
pi

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 423
An Example
• Suppose n = pe11 pe22 pe33 .
• Then
φ(n)
   
1 1 1
= n 1− 1− 1−
p1 p2 p3
    
1 1 1 1 1 1
= n 1− + + + + +
p1 p2 p3 p1 p2 p1 p3 p2 p3

1
− .
p1 p2 p3

• This may help convince you that Eq. (51) on 423 is


correct.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 424
Application: φ(2n )

φ(2n )
  
1
= 2n 1−
p
p | 2n ,p prime
 
1
= 2n 1 −
2
= 2n−1 .

Indeed, the only numbers in { 1, 2, . . . , 2n } relatively prime


with 2 are the 2n /2 = 2n−1 odd numbers.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 425
c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 426
Euler’s Phi Function Is Multiplicative
• Let n = m1 m2 , where gcd(m1 , m2 ) = 1.
• Let m1 = pe11 pe22 · · · pess be the prime factorization of m1 .
e e
• Let m2 = ps+1
s+1 s+2
ps+2 · · · pet t be the prime factorization of
m2 .
• From the formula on p. 422,
φ(m1 m2 ) = φ(n)
t  
1
= n 1−
i=1
pi
s   t  
1 1
= m1 1− m2 1−
i=1
pi i=s+1
pi
= φ(m1 ) φ(m2 ).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 427
An Identity for Euler’s Phi Function
Theorem 62 Let 1 = d1 < d2 < · · · < dm = n be the
+
m
positive divisors of n ∈ Z . Then i=1 φ(di ) = n.
• Define

Ai ≡ { k ∈ Z+ : gcd(k, n) = di , k ≤ n }.

• { A1 , A2 , . . . , Am } is a partition of { 1, 2, . . . , n }.
– For 1 ≤ i ≤ n, gcd(i, n) ∈ { d1 , d2 , . . . , dm }.
– And gcd(i, n) is unique.
m
• Thus n = i=1 | Ai |.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 428
The Proof (concluded)
• Now, k ∈ Ai if and only if k ≤ n and

gcd(k/di , n/di ) = 1.

• Hence

| Ai | = | { j ∈ Z+ : j ≤ n/di , gcd(j, n/di ) = 1 } |,

which equals φ(n/di ) by the definition of the phi


function.
• Finally,
m
 m
 m

n= | Ai | = φ(n/di ) = φ(di ).
i=1 i=1 i=1

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 429
A Loose Lower Bound for the Phi Functiona
Theorem 63 (Hardy & Wright, 1979)
φ(n) > n/(6 ln ln n) for n > 3.
a Godfrey Harold Hardy (1877–1947) and Edward Maitland Wright
(1906–2005).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 430
Godfrey Harold Hardy (1877–1947)

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 431
Permutations without Fixed Points
• Write a permutation f on { 1, 2, . . . , n } as
⎛ ⎞
1 2 ··· n
⎝ ⎠
f (1) f (2) ··· f (n)

• There are n! permutations.


• Permutation f has a fixed point at i if f (i) = i.
– i is invariant under f .
m
 

• When i is a fixed point, then f f · · · f (i) = i for any


m ≥ 0.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 432
Number of Permutations without Fixed Points
What is the number of permutations without fixed points?
• Let FX be the number of permutations that fix all i ∈ X.
• By the principle of inclusion and exclusion, the desired
number isa

(−1)|X| FX .
X⊆{ 1,2,...,n }

• FX = (n − | X |)! as those numbers not in X form a


permutation.
a Let ci denote the condition that i is a fixed
point. Then the desired number is N (c1 c2 · · · cn ) =
n k

k=0 (−1) 1≤i1 <i2 <···<ik ≤n N (ci1 ci2 · · · cik ) =
n k
  |X| F .
k=0 (−1) F
{ i1 ,i2 ,...,ik } { i1 ,i2 ,...,ik } = X⊆{ 1,2,...,n } (−1) X

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 433
The Proof (concluded)
• The desired number is
 n
  
n
(−1)|X| (n − |X|)! = (−1)k (n − k)!
k
X⊆{ 1,2,...,n } k=0
n
 (−1)k
= n! (52)
k!
k=0
n!
≈ ,
e
where e = 2.71828 . . . .
• A constant fraction of permutations have no fixed points!
• Or, if one picks a random permutation, with roughly
40% chance, that permutation will have no fixed points!

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 434
Derangements (Also P. 432)
• A derangement is a permutation of 1, 2, . . . , n in which
1 is not in the first place, 2 is not in the second place,
etc.a
• How many derangements of 1, 2, . . . , n are there?
• Let ci denote the condition that i is in the ith place.
• The desired number is N (c1 c2 · · · cn ), which equals
n   n
Δ n 1 n!
dn = (−1)i (n − i)! = n! (−1)i ≈ (53)
i=0
i i=0
i! e

by Eq. (52) on p. 434.


a Just a permutation without fixed points!

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 435
A Combinatorial Identity for dn
• Let dk denote the number of derangements of 1, 2, . . . , k.
• By convention, d0 = 1.
• Any permutation of 1, 2, . . . , n can have n − k fixed
points for some k, with the rest being deranged.
n n
• There are n−k = k choices for the fixed points.
• Hence
n  
 n
n! = dk . (54)
k
k=0

• Alternatively,
n
 dk
1= .
k! (n − k)!
k=0

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 436
An Example
One can numerically verify identity (54) on p. 436 with the
following data:

d0 = 1, d1 = 0,
d2 = 1, d3 = 2,
d4 = 9, d5 = 44,
d6 = 265,
d7 = 1854,
d8 = 14833,
d9 = 133496,
d10 = 1334961.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 437
A Variation on Derangement
• How many permutations of 1, 2, . . . , n are there such
that i is not in the (i − 1)st place for 2 ≤ i ≤ n?
– For example, 12345 (but not 23451).
• Let ci denote the condition that i is in the (i − 1)st place.
• Now N (ci ) = (n − 1)!, N (ci cj ) = (n − 2)! with i = j, etc.
• The desired number N (c2 c3 · · · cn ) equals
   
n−1 n−1
n! − (n − 1)! + (n − 2)! − · · ·
1 2
by the principle of inclusion and exclusion.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 438
A Variation on Derangement (continued)


n−1
n−1
(−1)i (n − i)!
i=0
i

n−1
(n − 1)! (n − i)
= (−1)i
i=0
i!

n−1
(n − 1)! (n − i)
= n! + (−1)i
i=1
i!

n−1
i n!
n−1
(n − 1)!
= n! + (−1) − (−1)i
i=1
i! i=1
(i − 1)!

n−1
i n!

n−1
(n − 1)!
= (−1) − (−1)i
i=0
i! i=1
(i − 1)!

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 439
A Variation on Derangement (concluded)


n−1
i n!

n−2
(n − 1)!
= (−1) + (−1)i
i=0
i! i=0
i!

n−1
i n!
n−2
(n − 1)!
= (−1) + (−1)i
i=0
i! i=0
i!
 
n! (n − 1)!
+ (−1)n + (−1)n−1
n! (n − 1)!

n
i n!
n−1
(n − 1)!
= (−1) + (−1)i
i=0
i! i=0
i!
= dn + dn−1 (55)

from Eq. (53) on p. 435.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 440
A Simpler Proof
• Again, how many permutations of 1, 2, . . . , n are there
such that i is not in the (i − 1)st place for 2 ≤ i ≤ n?
• Consider a permutation of 1, 2, . . . , n, where
1. i is not in the (i − 1)st place for 2 ≤ i ≤ n.
2. 1 is not in the nth place.
• There are dn of such permutations as they are but
derangements with the location restrictions shifted.
• The 2nd condition that 1 is not in the nth place is extra.
• So we need to add to dn the number of permutations
that satisfy condition 1 but not condition 2.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 441
A Simpler Proof (concluded)
• So consider permutations of 1, 2, . . . , n such that
1. i is not in the (i − 1)st place for 2 ≤ i ≤ n.
2. 1 is in the nth place.
• Remove 1 and rename i as i − 1 for 2 ≤ i ≤ n.
• The results are permutations of 1, 2, . . . , n − 1 such that
i is not in the ith place for 1 ≤ i ≤ n − 1.
• They are simply derangements of 1, 2, . . . , n − 1.
• Their count is dn−1 , as desired.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 442
Another Variation on Derangement
• Let A ⊆ { 1, 2, . . . , n }.
• How many permutations of 1, 2, . . . , n induce a
derangement of A?
– The original derangement is a special case with
A = { 1, 2, . . . , n }.
• Assume A = { 1, 2, . . . , m }, where m ≤ n, without loss
of generality.
• Let ci denote the condition that i is in the ith place.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 443
Another Variation on Derangement (concluded)
• The desired number is N (c1 c2 · · · cm ), which equals
m  
m
(−1)i (n − i)!
i=0
i

by the principle of inclusion and exclusion.


• Compare it with dn in Eq. (53) on p. 435:
n  
i n
(−1) (n − i)!.
i=0
i

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 444
Integer Solutions of a Linear Equation with Upper Bounds
Theorem 64 The number of integer solutions of
x1 + x2 + · · · + xn = r, where 0 ≤ x1 , x2 , . . . , xn < b, is
r/b
   
n n + r − mb − 1
(−1)m . (56)
m=0
m r − mb

• The number of nonnegative integer solutions of

x1 + x2 + · · · + xn = r

is  
Δ n+r−1
N=
r
by p. 85.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 445
The Proof (continued)
• Now impose upper bounds

0 ≤ x1 , x2 , . . . , xn < b.

• Let ci denote the condition that b ≤ xi .


• N (ci ): The number of solutions satisfying ci equals
 
n+r−b−1
r−b
as we are solving x1 + x2 + · · · + xn = r − b for
nonnegative integer solutions.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 446
The Proof (continued)
• N (ci cj ): The number of solutions satisfying ci ∧ cj with
i = j equals  
n + r − 2b − 1
r − 2b
as we are solving x1 + x2 + · · · + xn = r − 2b.
• And so on.
• Of course, we cannot satisfy more than
r/b conditions
ci .

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 447
The Proof (continued)
• Our goal is
N (c1 c2 · · · cn ).

• Recall the inclusion-exclusion principle (47) on p. 415:a


r/b

N (c1 c2 · · · cn ) = (−1)m Sm .
m=0

a The definition of Sm appeared on p. 414.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 448
The Proof (concluded)
n
• The number of N (ci ) terms in S1 is 1 .
n
• The number of N (ci cj ) terms in S2 is 2 .
• And so on.
• Finally,
r/b

N (c1 c2 · · · cn ) = (−1)m Sm
m=0
r/b
   
m n n + r − mb − 1
= (−1) .
m=0
m r − mb

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 449
An Example
• What is the number of positive integers x, where
x ≤ 999, whose sum of the 3 digits equals 20?
– E.g., 389 and 776.
• Use xi to denote x’s ith digit.
• Now the problem is equivalent to x1 + x2 + x3 = 20,
where 0 ≤ xi < 10.
• Equation (56) on p. 445 says the answer is
3 3+20−1 3 3+20−10−1 3 3+20−20−1
0 20 − 1 20−10 + 2 20−20 = 36.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 450
Generalized Principle of Inclusion and Exclusion Em
• Let Em denote the number of elements in S that satisfy
exactly m of the t conditions.
– The principle of inclusion and exclusion corresponds
to E0 .
– Recall Eq. (47) on p. 415:

E0 = S0 − S1 + S2 − · · · + (−1)t St .

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 451
Generalized Principle of Inclusion and Exclusion Em
(concluded)
• Thena
   
m+1 m+2
Em = Sm − Sm+1 + Sm+2
1 2
 
t−m t
− · · · + (−1) St
t−m
t  
k
= (−1)k−m Sk
k−m
k=m
t  
k−m k
= (−1) Sk . (57)
m
k=m

a The definition of Sk appeared on p. 415.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 452
The Proof
• If x ∈ S satisfies fewer than m conditions, then x should
contribute zero to Em .
– Indeed, it contributes zero to

Sm , Sm+1 , . . . , St .

• If x ∈ S satisfies exactly m conditions, then x should


contribute one to Em .
– It contributes one to Sm .
– It contributes zero to

Sm+1 , Sm+2 , . . . , St .

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 453
The Proof (continued)
• If x ∈ S satisfies m < r ≤ t of the conditions ci , then x
should contribute zero to Em .
r a
r
• Indeed, it is counted m times in Sm , m+1 times in
r
Sm+1 , . . ., and r times in Sr .
• It is counted zero times for all terms beyond Sr .
• The total count is therefore
r
   
k r
(−1)k−m .
m k
k=m

a Recall Eq. (48) on p. 415.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 454
The Proof (concluded)
By Newton’s identity (p. 32),
r    r   
k−m k r k−m r r−m
(−1) = (−1)
m k m k−m
k=m k=m
r−m
   
r r−m
= (−1)k
m k
k=0
  r−m
  
r r−m
= (−1)k
m k
k=0
 
r
= (1 − 1)r−m = 0.
m

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 455
Permutations with m Fixed Points
• Recall from p. 432 that a bijective function f on
{ 1, 2, . . . , n } has a fixed point at i if f (i) = i.
• What is the number of permutations with m fixed
points?
• Let ci denote the condition that i is a fixed point.
• Thena  
n n!
Sk = (n − k)! = . (58)
k k!
a The definition of Sk appeared on p. 415.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 456
The Proof (concluded)
• From Eq. (57) on p. 452,
n
  
k
Em = (−1)k−m Sk
k−m
k=m
n  
k−m k n!
= (−1)
k − m k!
k=m
n
n!  k−m 1
= (−1) .
m! (k − m)!
k=m

• For example, En−2 = n(n − 1)/2 (permutations with


n − 2 fixed points).

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 457
Generalized Principle of Inclusion and Exclusion Lm
• Let Lm denote the number of elements in S that satisfy
at least m of the t conditions.
• Thena
   
m m+1
Lm = Sm − Sm+1 + Sm+2
m−1 m−1
 
t−1
− · · · + (−1)t−m St
m−1
t  
k − 1
= (−1)k−m Sk . (59)
m−1
k=m

a Compare
t k−m
k
it with Eq. (57) on p. 452: Em = k=m (−1) m
Sk .

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 458
The Proof
• By definition,
Lm − Lm+1 = Em
for m < t by definition.
• Now we prove the identity by induction on m.
• First note that Et = Lt = St .
• Inductively, assume that
t
  
k−(m+1) k − 1
Lm+1 = (−1) Sk .
m
k=m+1

t k−m k

• Also Em = k=m (−1) m Sk from (57) on p. 452.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 459
The Proof (concluded)
• Finally, Lm equals

Lm+1 + Em


t
k−1
t
k
= (−1)k−(m+1) Sk + (−1)k−m Sk
m m
k=m+1 k=m
 
t
k−1 k
= Sm + (−1)k−m − + Sk
m m
k=m+1

t
k−1
= Sm + (−1)k−m Sk by Lemma 2 on p. 31
m−1
k=m+1

t
k−1
= (−1)k−m Sk .
m−1
k=m

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 460
Permutations with Fixed Points
• Consider permutations of { 1, 2, . . . , n }.
• Let ci stand for the condition that i is a fixed point.
• From Eq. (59) on p. 458 with m = 1, the number of
permutations with at least one fixed point is
t

L1 = (−1)k−1 Sk .
k=1

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 461
The Proof (concluded)
• Recall that Eq. (58) on p. 456 says
n!
Sk = .
k!
• Hencea
n

L1 = (−1)k−1 Sk
k=1
n

k−1 1
= n! (−1) (60)
k!
k=1
 
1
≈ n! 1 − .
e
a An alternative proof is via Eq. (52) on p. 434.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 462
Checking for Consistency
• The sum of the number of permutations without fixed
points (E0 ) and those with fixed points (L1 ) should be
n!.
• Indeed, from Eq. (52) on p. 434 for E0 and Eq. (60) on
p. 462 for L1 ,
n
 n

(−1)k (−1)k−1
n! + n! = n!.
k! k!
k=0 k=1

• Note that E0 is dn , the number of derangements.

c
2018 Prof. Yuh-Dauh Lyuu, National Taiwan University Page 463

You might also like