Roots of Unity Filter Part 4 - Proof

Note

I originally wrote a three part series back in 2019 that covered the roots of unity filter, a technique that I used a couple times during my stint with competitive math. However, I never really had a proof for why the roots of unity filter worked and I instead just had empirical evidence that it would work for all cycle lengths between 22 and 1010 and all of their offsets. This was enough for me to use it in my competitive math career, but I always felt uneasy that I left such a big hole on my website that was saying "just trust me." Six years later and after graduating both high school and college, I'm finally revisiting this to provide a proof 😅. It isn't necessarily that difficult or insightful, but it feels wrong to leave something up for so long that was unproven.

Recap

As a reminder, the roots of unity filter says that given a polynomial of degree nn:

P(x)=a0+a1x+a2x2+⋯+xn−1P(x) = a_0 + a_1x + a_2x^2 + \dots + x^{n-1}

a period length mm, and an offset bb, we have:

∑i=0;mi+b<nami+b=∑j=0m−1bjP(ωj)m\sum_{i = 0; mi + b < n} a_{mi + b} = \frac{\sum_{j=0}^{m-1} b_j P(\omega^j)}{m}

where ω\omega is the mmth root of unity and the coefficients bjb_j are:

bj=ω−(bj%m)b_j = \omega^{- (bj \% m)}

For our proof, we will multiply both sides of our expression by mm to get:

m⋅∑i=0;mi+b<nami+b=∑j=0m−1bjP(ωj)m \cdot \sum_{i = 0; mi + b < n} a_{mi + b} = \sum_{j=0}^{m-1} b_j P(\omega^j)

Handling b=0b = 0

We first handle the simpler case where there is no offset, or b=0b = 0. In reality, we could provide a general proof that does not handle this separately, but I think the b=0b = 0 case is easier to digest and parts of it are used in the general case.

In this case, we have bj=ωm=1b_j = \omega^m = 1 for all jj. As a result, our RHS sum becomes just P(1)+P(ω)+⋯+P(ωm−1)P(1) + P(\omega) + \dots + P(\omega^{m-1}). Our LHS is the sum of all coefficients amia_{mi} for all ii multiplied by mm.

We focus on the coefficient of amia_{mi} for any i>0i > 0. On the LHS, this is mm. We do the same for the RHS for each of the terms P(ωj)P(\omega^j). The term of note is amiωmija_{mi} \omega^{mij}. Since ωm=1\omega^m = 1, we have this term is just amia_{mi}, showing the coefficient is 11 for each of the mm different terms. Therefore, the total coefficient of amia_{mi} is mm on the RHS, matching the LHS.

We then look at the coefficient of any other term ami+xa_{mi + x} for any i>0i > 0 and 0<x<m0 < x < m. Here, we have the LHS side coefficient is 00. For each of the RHS terms P(ωj)P(\omega^j), the term of note is ami+xω(mi+x)ja_{mi + x} \omega^{(mi + x)j}. Focusing on this ω\omega term, we get: ωmij⋅ωxj=ωxj\omega^{mij} \cdot \omega^{xj} = \omega^{xj}

Therefore, our RHS coefficient for ami+xa_{mi + x} is given as:

∑j=0m−1ωxj\sum_{j=0}^{m-1} \omega^{xj}

We apply the geometric sum formula, which is applicable since ω≠1\omega \neq 1:

∑j=0m−1ωxj=1−(ωb)m1−ωx=1−11−ωx=0\sum_{j=0}^{m-1} \omega^{xj} = \frac{1 - (\omega^b)^m}{1 - \omega^x} = \frac{1 - 1}{1 - \omega^x} = 0

As a result, our RHS coefficient for ami+xa_{mi + x} is 00. This covers all possible terms, proving the b=0b = 0 case for the roots of unity filter.

Handling b>0b > 0

We use the same proof structure, except in this case, we no longer have bj=1b_j = 1 and instead will get some power of ω\omega. We first focus on the coefficient of ami+ba_{mi + b}, which is mm on the LHS. For the RHS, we note that the term of note in each P(ωj)P(\omega^j) is:

ami+b⋅ω(mi+b)j⋅ω−(bj%m)=ami+b⋅ωbj−(bj%m)a_{mi + b} \cdot \omega^{(mi + b)j} \cdot \omega^{- (bj \% m)} = a_{mi + b} \cdot \omega^{bj - (bj \% m)}

Note that the exponent of ω\omega must be divisible by mm, meaning the coefficient evaluates to just 11 for each of the mm terms, leading to a total contribution of mm.

Next, we focus on the coefficient of a_mi+b+xa\_{mi + b + x} for any i>0i > 0 and 0<x<m0 < x < m. This has a LHS coefficient of 00, and the RHS coefficient is given as:

∑j=0m−1ω(mi+b+x)j⋅ω−(bj%m)\sum_{j=0}^{m-1} \omega^{(mi + b + x)j} \cdot \omega^{- (bj \% m)}

We can simplify this to:

∑j=0m−1ωbj−(bj%m)+xj\sum_{j=0}^{m-1} \omega^{bj - (bj \% m) + xj}

Applying the insight from the ami+ba_{mi + b} case, we have ωbj−(bj%m)\omega^{bj - (bj \% m)} is just 11, and we are left with:

∑j=0m−1ωxj\sum_{j=0}^{m-1} \omega^{xj}

This is the exact same expression as in the b=0b = 0 case, where we showed this evaluates to 00, thus proving the general case.

Birthday Paradox + Meet in the Middle
Home
No Next Post