714-11-2020 Finite Fourier Analysis
714-11-2020 Finite Fourier Analysis
Proof. If n | a, then each term in the sum is 1, so things are clear. Otherwise, write
n−1
X ζ an − 1
ζ ja = = 0.
ζa − 1
j=0
F (X) = c0 + c1 X + c2 X 2 + · · ·
Then
f (1) + f (ζ) + · · · + f (ζ n−1 )
c0 + cn + c2n + · · · = .
n
An oft-cited example of the roots of unity filter are problems of the following flavour.
Example
Compute
2020 2020 2020 2020
+ + + ··· + .
0 4 8 2020
Equipped with the roots of unity filter, we can transform certain problems of combinatorics into problems
of algebra. A more complex (pardon the pun) example showcases the power of this method. It first
appeared in competitive mathematics in a Bulgarian TST in 2006 before making a reprisal in the British
MO in 2019.
1
() Finite Fourier Analysis
Solution. Let N denote the subsets with the desired property and ζ a p-th root of unity. (We count the
empty subset.) By proposition 1.1,
p−1 P
1 X X j b∈B b
N= ζ .
p
B⊆A j=0
Hence the combinatorial problem, which is not at all an easy one, is reduced to a purely algebraic
exercise. After swapping the order of summation,
p−1 P
1 X X j b∈B b
N= ζ
p
j=0 B⊆A
p−1 p−1
1 X Y
= (1 + ζ jk )
p
j=0 k=1
It is worth noting that the expressions that result from swapping the order of summation after applying
the roots of unity often behave very differently when j = 0. Indeed, in this case, when j = 0 the inner
product evaluates to 2p−1 . On the other hand, if j 6= 0, then (ζ j , ζ 2j , . . . , ζ (p−1)j ) is a permutation of
(ζ, ζ 2 , . . . , ζ p−1 ). Hence
p−1
!
1 p−1
Y
k
N= 2 + (p − 1) (1 + ζ ) .
p
k=1
It is possible to evaluate the final product via direct expansion. We proceed with a more efficient
method, however. Let
p−1
Y
p−1
f (x) = 1 + x + · · · + x = (1 − ζ k )
k=1
p−1
Y
=⇒ (1 + ζ k ) = (−1)p−1 f (−1) = 1 − 1 + · · · + 1 = 1.
k=1
2p−1 +p−1
Thus N = p .
This problem demonstrates a number of important themes about the roots of unity filter.
1. Swapping sums is extremely useful and sometimes even the entirety of the problem.
3. Solutions will often invoke properties of the roots of unity, particularly their relationship with
polynomials.
Notice that it is possible to skip the first few steps in theQabove solutions if instead Proposition
proposition 1.2 is applied to the generating function f (X) = p−1 k
k=1 (1 + X ). The step of swapping the
sums and rewriting the expressions is essentially equivalent to finding the generating function for the
problem at hand.
Why, then, even bother showing proposition 1.1 at all? There are two reasons. The first is that in
some instances it is not easy and also not necessary to spot the relevant generating function. Problems
3.5 and 3.15 are good examples of this.
Second, proposition 1.1 exemplifies the general usefulness of indicator functions, a profoundly useful
tool which is by no means limited to merely the roots of unity filter as seen in olympiad mathematics.
2
() Finite Fourier Analysis
2 Gauss sums
This section assumes a familiarity with the properties of quadratic residues.
2πi
Solution. Let N be the number of solutions and ζ = e p . Applying proposition 1.1,
p−1
1 X X j(x21 +x22 +···+x2n −1)
N= ζ
p
xi ∈Fp j=0
p−1 p−1
!
1 X −j Y jx2
= ζ ζ
p
j=0 x=0
p−1 p−1
!n
1 X X 2
= pn−1 + ζ −j ζ jx
p
j=1 x=0
Let G(a) = p−1 ax2 . These are known as the quadratic Gauss sums modulo p. For brevity’s sake, we
P
x=0 ζ
also write G(1) = G. There are several well known facts about the Gauss sums that are not difficult to
prove
Claim 1.
a
G(a) = G
p
Proof. When p divides a, things are clear. If ap = 1, then x → ax2 is a permutation of the quadratic
residues mod p. Hence, in this
case G(a) = G.
a
On the other hand, if p = −1, then x → ax2 maps to zero exactly once and to each quadratic
non-residue twice. Hence
X p−1
X X
x
G(a) = 1 + 2 ζ =2 ζx − 2 ζ x − 1 = −G.
x=0
x x
p
=−1 p
=1
Thus
p−1 n
1 X −j j
N = pn−1 + ζ Gn .
p p
j=1
If n is even, then all that is left to is compute G. Conversely, if n is odd we will need to invoke the
following proposition:
Claim 2.
p−1
X x
G= ζx
p
x=0
3
() Finite Fourier Analysis
Proof. Rewrite
p−1
X x X X
ζx = ζx − ζx
p
x=0
x x
p
=1 p
=−1
X X x X
ζx − ζ x
=2 ζ +
x x x
p
=1 p
=1 p
=−1
= G − 1 − (−1) = G.
Therefore
Gn
(
pn−1 − p if n is even,
N= Gn+1
pn−1 − p if n is odd.
We don’t even need a precise value of G, then. It is enough to find G2 , which is much easier.
Claim 3.
2 −1
G =p .
p
Proof. By claim 1
2 −1
G = G · G(−1)
p
p−1 X
X p−1
−1 2 −y 2
= ζx
p
x=0 y=0
X
−1
= ζ (x−y)(x+y) .
p x,y
X p−1 X
X p−1
(x−y)(x+y)
ζ = ζ uv = p
x,y u=0 v=0
We conclude ( n(p−1) n
pn−1 − (−1) 4 p 2 −1 if n is even
N= (n+1)(p−1) n−1
pn−1 − (−1) 4 p 2 if n is odd.
4
() Finite Fourier Analysis
Proof. Take n = q in example 2.1. Any tuple (x1 , x2 , . . . , xq ) can be cyclically shuffled in q ways to
produce distinct
solutions unless the xi are all equal. The number of ways for the xi to be all equal is
q
precisely p + 1. Thus
q−1 p−1 q−1 q−1
· q
p + (−1) 2 2 p 2 ≡ (mod q).
p
q−1
Recall that p 2 ≡ legendrepq (mod q), and the result is immediate.
5
() Finite Fourier Analysis
3 Problems
Many problems are taken from Problems from the Book by Titu Andreescu and Gabriel Dospinescu.
Problem 3.1 (IMC 1999). We roll a regular die n times. What is the probability that the sum of the
numbers shown is a multiple of 5?
Problem 3.2. Let n be a positive integer and p an odd prime. Find the number of tuples (x1 , . . . , xp−1 )
of positive integers
p | x1 + 2x2 + · · · + (p − 1)xp−1
and xi ≤ n.
Problem 3.3 (IMO Shortlist 1987). Three persons, A, B, C play the following game: A subset with k
elements of the set {1, 2, . . . , 1986} uniformly at random. The winner is A, B, or C according to whether
the sum of the elements of the selected subset is congruent to 0, 1, or 2 modulo 3. Find all values of k
for which A, B, C have equal chances of winning.
Problem 3.4. How many 100-element subsets of the set {1, 2, . . . , 2000} have the sum of their elements
a multiple of 5?
Problem 3.5 (IMO 1995). Let p be an odd prime number. How many p-element subsets A of
{1, 2, . . . , 2p} are there, the sum of whose elements is divisible by p?
Problem 3.6 (Rioplatense Olympiad). Find the number of subsets S of {1, 2, ..., n} which satisfy the
following condition: the difference between the number of even elements and odd elements of S is
divisible by 3.
Problem 3.7 (Gabriel Dospinescu). Let f (n) be the number of subsets of {1, 2, 3, . . . , n} whose elements
sum to 0 (mod n). (The empty set is included.) Prove that
1 X
f (n) = ϕ(d)2n/d .
n
d|n
d odd
Problem 3.8 (China TST 2010). Colour each element x ∈ M = {1, 2, . . . , n} either red, blue or yellow.
Let
A = (x, y, z) ∈ M 3 | x, y, z are the same colour and n | (x + y + z)
and define
B = (x, y, z) ∈ M 3 | x, y, z are distinct colours and n | (x + y + z) .
Determine which n have the following property: if we color any 75 elements of S red, then at least half
of the n-tuples in Tn have an even number of coordinates with red elements.
Problem 3.10 (IMO Shortlist 1999). Let p > 3 be a prime number. For each nonempty subset T of
{0, 1, 2, 3, . . . , p − 1}, let E(T ) be the set of all (p − 1)-tuples (x1 , . . . , xp−1 ), where each xi ∈ T and
x1 + 2x2 + . . . + (p − 1)xp−1 is divisible by p. Prove that
6
() Finite Fourier Analysis
Problem 3.12 (China TST 2017). Find the number of ordered arrays (x1 , ..., x100 ) that satisfies the
following conditions:
Problem 3.13 (St Petersburg MO 1991). We call a finite sequence {ak }1≤k≤n , p-balanced if the sums
Problem 3.14 (Erdos-Sun). Prove that if a family of k arithmetic progressions covers 2k consecutive
integers, then it covers all of Z.
Problem 3.15 (St. Petersburg MO). Let p be a prime and n ≥ p and a1 , a2 , . . . , an be integers.
P Let
f0 = 1 and fk be the number of subsets I ⊂ {1, 2, 3 . . . , n} such that |I| = k and p divides i∈I ai .
Prove that p divides
Xn
fk (−1)k .
k=0
Problem 3.16 (Math Reflections). Let p be a prime and n, s positive integers. Prove that pq divides
k n
X
(−1)
k
0≤k≤n
p|k−s
j k
n−1
where q = p−1
Problem 3.17 (USA TST 2010). Determine whether or not there exists a positive integer k such that
p = 6k + 1 is a prime and
3k
≡ 1 (mod p).
k
7
() Finite Fourier Analysis
Solutions
3.1 Let P denote the probability. By the roots of unity filter,
4 4
1 X X
j(x1 +x2 +···+xn ) 1 X j
P = ζ = (ζ + ζ 2j + · · · + ζ 6j )n
5 · 6n 5 · 6n
1≤xi ≤6 j=0 j=0
ζ j + ζ 2j + · · · + ζ 6j = ζ 6j = ζ j
for j 6= 0. Hence
4
(
1 1
1 1 X jn 5 − 6n if 5 divides n,
P = + ζ =
5 5 · 6n 1
5 otherwise.
j=0
2πi
3.2 Let N denote the number of such tuples and ζ = e p . Applying the roots of unity filter,
p−1
1 X X j(x1 +2x2 +···+(p−1)xp−1
N= ζ
p
xi ≤n j=0
p−1 p−1
1 X Y jk
= (ζ + ζ 2jk + · · · + ζ jkn )
p
j=0 k=1
p−1 p−1
np−1 1 X Y ζ(ζ jkn − 1)
= +
p p ζ jk − 1
j=1 k=1
jkn
−1)
If n is divisible by p, then ζ(ζζ jk −1 for all j, k. On the other hand, if n is not divisible by p, then
jk → jkn is a permutation mod p, so
p−1
Y ζ(ζ jkn − 1)
= 1.
ζ jk − 1
k=1
Thus
np−1
(
p if p divides n.
N= np−1 +p−1
p if p does not divide n.
2πi
3.3 Let ζ = e 3 . Consider the quantity
X P
N= ζ t∈T t = c0 + c1 ζ + c2 ζ 2 .
T ⊆S
|T |=k
The three are equal if and only if N = 0. (This is a corollary of the fact that 1 + X + X 2 is the minimal
polynomial of ζ. See the solution to the next problem for a more complete explanation.) However, N is
precisely the coefficient of X k in the polynomial
Thus the answer is the integers between 1 and 1986 not divisible by 3.
2πi
3.4 Let ζ = e 5 and N denote the number we are seeking. By the roots of unity filter,
4
1X X P
N= ζ j s∈S s
5
j=0 S⊆[2000]
|S|=100
8
() Finite Fourier Analysis
On one hand
N = c0 + c1 ζ + · · · + cp−1 ζ p−1 ,
where the numbers ci represent the number of subsets S of {1, 2, . . . , 2p} with size p that have a sum i
(mod p). On the other hand, N is the coefficient of X p in
(X + ζ)(X + ζ 2 ) · · · (X + ζ 2p ) = (X p + 1)2 ,
2p
p −2
c0 = .
p
3.6 Let ζ be a primitive third root of unity and N be the number we are seeking. Suppose first that n
is even and write n = 2m. Then
m
X m X k
N= .
k `
k=0 k≡` (mod 3)
Thus
m m 2
1 X m X m X j(k−`)
N= ζ
3 k `
k=0 `=0 j=0
2 m
! m !
2n X X m jk X m
−j`
= + ζ ζ
3 k `
j=1 k=0 `=0
2
1 X
= (1 + ζ j )m (1 + ζ −j )m
3
j=0
2n 2
= + (1 + ζ)m (1 + ζ 2 )m
3 3
2n + 2
=
3
The case where n is odd is left as an exercise.
9
() Finite Fourier Analysis
2πi
3.7 Let ζ = e p . Applying the roots of unity filter,
p−1 n
1 XY
f (n) = (1 + ζ jk )
n
j=0 k=1
Suppose that ζ j is a root of unity of order d. (1, ζ jk , . . . ζ n(p−1) ) counts each of the roots of unity
(1, ζ, . . . , ζ d−1 ) exactly n/d times. Thus
d−1
!n/d
1X Y
k
f (n) = ϕ(d) (1 + ζ ) .
n
d|n k=1
d−1
(
Y
k d−1 2 if d is odd,
(1 + ζ ) = (−1) g(−1) =
k=1
0 otherwise.
Therefore
p−1
2X 3
2|A| − |B| = Rj + Bj3 + Yj3 − 3Rj Bj Cj
p
j=0
p−1
2 X
= (Rj + Bj + Yj )(Rj2 + Bj2 + Yj2 − Bj Yj − Yj Rj − Rj Bj ))
p
j=0
Let M and N denote the number of tuples in Tn with even and odd coordinates, respectively. By the
roots of unity filter, the number of tuples with precisely k red elements is given by
100
1 n X k n−k
Rj Bj .
100 k
j=0
10
() Finite Fourier Analysis
Thus
99
!
1 X X n X n
M −N = Rjk Bkn−k − Rjk Bjn−k
100 k k
j=0 k even k odd
99
1 X
= (Bj − Rj )n
100
j=0
The quantity
99
1 X n
Bj (†)
100
j=0
counts the number of tuples in Tn with only blue coordinates, so it is non-negative. Hence if n is even,
the quantity M − N is non-negative, and we are done.
On the other hand, consider colouring all b ≡ 2 (mod 4) blue for odd n. Then the quantity in (†) is
zero, so M − N = −50n−1 < 0.
2πi
3.10 Let ζ = e p . Applying the roots of unity filter,
p−1
1 X X
|E({0, 1, 2})| = ζ j(x1 +2x2 +···+(p−1)xp−1 )
p
xi ∈{0,1,2} j=0
p−1 p−1
1XY
= (1 + ζ ij + ζ 2ij )
p
j=0 i=1
p−1 p−1
3p−1 X Y ζ 3ij − 1
= +
p ζ ij − 1
j=1 i=1
3p−1 + (p − 1)
= .
p
Likewise, if α, β, γ are the roots of the polynomial X 3 + X + 1, then
p−1 p−1
3p−1 1 X Y
|E({0, 1, 3})| = + (1 + ζ ij + ζ 3ij )
p p
j=1 i=1
p−1 p−1
3p−1 1 X Y
= + (ζ i − α)(ζ i − β)(ζ i − γ)
p p
j=1 i−1
3p−1 p − 1 (αp − 1)(β p − 1)(γ p − 1)
= + · .
p p (α − 1)(β − 1)(γ − 1)
−1)(β −1)(γ −1) n n n
Hence it suffices to prove ap ≥ 1 with equality if and only if p = 5 where an = (α(α−1)(β−1)(γ−1) .
n n n n n n n
Because an is a linear combination of α , β , γ , (αβ) , (βγ) , (γα) , and (αβγ) , it follows that an
satisfies a recursion with the characteristic polynomial
(X − α)(X − β)(X − γ)(X − αβ)(X − βγ)(X − γα)(X − αβγ)
= (X 3 + X + 1)(X 3 − X 2 − 1)(X + 1)
= x7 − 2x3 − 2x2 − 2x − 1
11
() Finite Fourier Analysis
Thus there exists a constant C such that the sequence an obeys the recursive relation
3.12 The answer is 201798 . Let p = 2017 and N denote the number of such ordered arrays. By the
roots of unity filter,
p−1 p−1
a(x21 +x22 +···+x2100 )
X X X
2
p N= ζ ζ b(x1 +x2 +···+x100 )
(x1 ,...,x100 ) a=0 b=0
p−1 X
p−1 X
p−1
!100
2 +bx
X
= ζ ax
a=0 b=0 x=0
Before proceeding, we take a moment to deal with the case a = 0. Since 1 + ζ b + · · · + ζ b(p−1) = 0 if
b 6= 0, we have
p−1 Xp−1
!100
X
bx
ζ = p100 .
b=0 x=0
In order to apply our knowledge about Gauss sums, we complete the square:
p−1 X
p−1 p−1
!100
2
− 25b b 2
X X
2 100 a(x+ 2a )
pN = p + ζ a ζ .
a=1 b=0 x=0
b
Since x → x + 2a is a permutation, it follows that
p−1 X
p−1
X 25b2
2
p N =p 100
+ ζ− a G(a)100 .
a=1 b=0
p−1 X
p−1 2
− 25b
X
= p100 + p 50 a ζ
a=1 b=0
100 50
X
p−1 25
=p +p + a=1 G −
a
p−1
100 50
X −25/a
=p +p G
p
a=1
= p100
The final step comes from the fact that a → −25/a is bijective, so
p−1 p−1
X −25/a X a p−1 p−1
G= G=G· −G· .
p p 2 2
a=1 a=1
12
() Finite Fourier Analysis
3.13 For the moment, fix a prime p and pick an arbitrary primitive p-th root of unity ζ. Consider the
function
f (X) = a1 X + a2 X 2 + · · · + a50 X 50 .
Because S(1, p) = S(2, p) = · · · = S(p, p), it follows that
p
X
f (ζ) = S(k, p)ζ k = 0.
k=1
There are 2 + 4 + 6 + 10 + 12 + 16 = 50 roots of unity with order 3, 5, 7, 11, 13, or 17, so it follows that f
has 51 roots (0 as well). Thus f (X) = 0, and so the ai are all zero.
2πi
3.14 Denote the arithmetic progressions by {ai + tdi }t∈Z . Let ζj = e dj . An integer n belongs to one of
the arithmetic sequences if and only if
k
m−aj
Y
1 − ζj = 0.
j=1
−a
where αS = (−1)S j∈S ζj j and zS = j∈S ζj . Let un = S⊆[k] αS zSn , so n belongs to one of the
Q Q P
arithmetic progressions if and only if un = 0. The un satisfy a linear recurrence of order 2k ; for proof,
consider the polynomial
k
Y
f (X) = (X − zS ) = c0 + c1 X + · · · + c2k X 2 .
S⊆[k]
Because the arithmetic progression covers 2k consecutive integers, it follows that 2k consecutive terms
un are zero, so un = 0 for all n ∈ Z.
3.15 Applying the roots of unity filter (verify the equality when k = 0):
n n p−1
X
k
X (−1)k X X P
fk (−1) = ζj i∈I ai
p
k=0 k=0 I⊆[n] j=0
|I|=k
n p−1 X
(−1)k n
X X P
j i∈I ai
=
p + ζ
k
k=0 j=1 I⊆[n]
|I|=k
p−1
1X X P
= (−1)|I| ζ j i∈I ai
p
j=1 I⊆[n]
p−1 n
1 XY
= (1 − ζ jai )
p
j=1 i=1
Denote this quantity by N . To prove this divisibility, we invoke some p-adic theory. Let S = {f (ζ) |
f ∈ Z[x]} and n · S = {nz | z ∈ S} for any integer n. First we establish a useful lemma:
13
() Finite Fourier Analysis
Proof. By definition, there exists an integer polynomial f such that nf (ζ) = N . Since the minimal
polynomial of ζ has degree p − 1, there are integers a0 , a1 , . . . , ap−2 such that
1
Let 1 − ζ = ξ. We claim that ξ p−1 ∈ p · S. (Think of this as saying νp (ξ) = p−1 when the notion of νp is
extended to a ring of algebraic integers Ok over the field Q(ζ). For more information, research p-adic
numbers. Here we use just elementary methods.) Observe that
p
p
X p p
ζ = 1 = (1 − ξ) = (−ξ)k .
k
k=0
It follows that
p−1
p−1
X p
ξ = (1 − ζ k−1 ) ∈ p · S.
k
k=1
Then N ∈ pn · S. Moreover, N p−1 ∈ p(p−1)n . Since n ≥ p, it follows that N p−1 is divisible by pn , which
implies N is divisible by p2 .
2πi
3.16 The solution proceeds very similarly to the previous problem Let ζ = e p . By the roots of unity
filter,
p−1 n
X n 1 XX
(−1)k = (1 − ζ j(k−s) )n
k p
0≤k≤n j=1 k=0
p|k−s
When j = 0, every term is 0. As in the previous problem, let S = {f (ζ) | f ∈ Z[x]} and n · S = {ns |
s ∈ S}. Then (1 − ζ)p−1 ∈ p · S. It suffices to show that
p−1 X
X n
q+1
p | (1 − ζ j(k−s) )n
j=0 j=0
Since n > q(p − 1), it follows that N p−1 ∈ pq(p−1)+1 S, so pq+1 divides N , as desired.
3.17 This solution does not concretely apply the roots of unity filter (no complex numbers are used),
but heavily employs its spirit. It is meant to demonstrate that the roots of unity filter is only the tip
of a much larger mathematical iceberg. An interested reader is encouraged to research finite Fourier
analysis. For now, here is the solution to the problem.
The answer is negative. All work is done in Z/pZ.
14
() Finite Fourier Analysis
Let ζ be an element of Z/pZ with order k (i.e. ζ is a k-th root of unity). Then
k−1 3k k−1
1X 1 X 3k X ji 3k 3k 3k 3k
(1 + ζ j )3k = ζ = + + + .
k k i 0 k 2k 3k
j=0 i=0 j=0
3k
Suppose for the sake of contradiction that k = 1. Then
k−1
X
(1 + ζ j )3k = 4k.
j=0
15