Roots of Unity Filter Part 3 - Roots of Unity Filter
Note
This is a three part series I wrote back in 2019 on a technique applicable to certain competitive math problems: roots of unity filters. See the first two parts for a recap of complex numbers and roots of unity respectively. This post will actually go over the technique as well as what kind of problems it can be applied to.
Warning
Many of the explanations for this section will not be rigorous proofs.
Guiding Problem
The main problem we are trying to tackle in this section is the following from one of Thomas Mildorf's mock AIMEs:
Example
Problem from Thomas Mildorf's Mock AIME 1: #11
Let denote the value of the sum
Determine
We can tackle this problem in a variety of ways, but the approach we will be using here is a technique known as roots of unity filter.
Description
Roots of unity filter is a technique that allows us to find the sum of every th coefficient in a polynomial with any given offset less than . For instance, if you had a polynomial with a degree of , you could find the sum of the 2nd, 5th, 8th, ..., and 20th coefficients. This would correspond to every 3rd coefficient with an offset of .
While on its own the roots of unity filter doesn't have a lot of applications, it is especially powerful when applied to the binomial theorem. For instance, with the guiding problem, we can expand the summation to find the following;
We can see that this problem is asking us to calculate the sum of every 6th binomial coefficient with an offset of and then subtract the sum of every 6th binomial coefficient with an offset of .
We can apply the roots of unity filter if we had a polynomial that had binomial coefficients as its coefficients. We can obtain this with the following polynomial:
To solve our problem from above, we can utilize the root of unity filter on this polynomial with to determine the sum of every 6th coefficient with offset and the sum of every 6th coefficient with offset . Then, we can subtract the latter from the former and obtain the answer.
No Offset Version
The simplest method to apply roots of unity filter is when you're dealing with an offset of since you don't have to do much work. If you want to find the sum of every th coefficient with an offset of for a polynomial , you can calculate it with the following expression, where represents the smallest root of unity:
Essentially, we just have to plug in the th roots of unity, where is the desired cycle length, and then take the average of the results.
Explanation
To see why this works, we can utilize the following two facts that we proved previously about roots of unity:
Armed with this information, we can examine what happens when we plug the roots of unity into the polynomial . For this section, we're going to use a polynomial with a degree of and calculate the sum of every third term. However, this can be generalized to any degree polynomial for any cycle length. First of all, let's write a polynomial with a degree of as the following:
When we plug in as our root of unity, we obtain the following:
However, note that when the power of exceeds , we can factor out . This means that after the term , the powers of will repeat in a cycle of length . We can show this result with the other powers of we are plugging in as well. Whenever we pass in our polynomial after passing in to the polynomial, we can factor out that .
Since the terms of all of the polynomials are cyclic when plugging in the roots of unities, if we can show that summing all of the polynomials makes it so that only the coefficient of remain, it will necessarily apply to as well. Therefore, we can direct our focus to what happens with the first terms of the polynomial when we pass in , and .
We can make the following chart to look at what happens:
Root of Unity | ||||
---|---|---|---|---|
Total Sum |
The columns each correspond to what power we are raising each of the roots of unity, while the rows indicate each of the roots of unity. If we sum all of the columns, we will obtain how much of each coefficient we shall receive in the final sum.
Note that from the equation
all of the columns except for the one corresponding to end up with a sum of . In the third column, the equation is applied with just plugged in, and in the fourth column, the equation is applied with plugged in. Therefore, our result is just added times, so we can divide by to obtain our desired sum.
Again, remember that since the roots of unity are cyclic with a period of , the same values and chart will apply for through , through , etc. To see this, looking at the entire chart is useful, which is placed below for your convenience.
Total Sum |
Example
Find without calculating any binary coefficients
We can approach this problem by first realizing that we need to find the sum of every 4th coefficient in the polynomial:
By applying the roots of unity filter, we can realize that this is equivalent to the following:
We can then find this sum by converting each of the complex numbers to polar form, applying de Moivre's theorem, and then converting back to rectangular coordinates. While this may seem lengthy for a problem we could have just calculated the binomial coefficients for, it is a general technique that has the same number of terms even as the upper number increases to huge numbers.
We continue the calculation below for the sake of completeness:
To check our answer, we can compute the binomial coefficients manually and get .
Note
A frequent math competition technique is to plug and into a polynomial , add them together, and then divide by to cancel out all of the odd degree terms. This is actually the roots of unity filter being used with since and are the second roots of unity!
With Offset Version
While the previous version of roots of unity filter is already pretty powerful and can solve a lot of math problems, the more general version to find sums with offsets. Note that we still cannot solve our guiding problem because, in that problem, we have to be able to calculate the sum of the coefficients with a period pf , but with an offset of .
To get an idea of how this will work, we can once again look at the chart we created earlier that matches up what happens when we plug in each of the roots of unity for the terms in our polynomial.
Root of Unity | ||||
---|---|---|---|---|
Total Sum |
Note that the main reason this worked out was that we had appear in every row for the term we wanted: . That way, when we summed up the polynomial evaluated at each of the roots of unity, everything else would cancel out via the crucial identity
but the s would not.
This time, say that the desired coefficient is , meaning that we want an offset of instead of . To do this, the key is to add some coefficient in front of each term in our sum to ensure that our sum has s in the column for our desired term: . Then, if we called those coefficients , the sum of every 3rd term with an offset of 1 would look like this:
To calculate these coefficients, we can use our table from above. Currently, it would look something like this, where all of our coefficients would be , meaning that the values for each row are not being changed.
Root of Unity | |||||
---|---|---|---|---|---|
Total Sum |
However, by using the crucial property that , we can adjust the coefficients for each row so that the s appear in the column for instead:
Root of Unity | |||||
---|---|---|---|---|---|
Total Sum |
With these coefficients chosen carefully, each sum now conveniently produces the values for !
Note
I currently don't have a good explanation for why all of the other columns conveniently end up still canceling each other out no matter which column you choose to make the s generate in. To show that they do cancel out to (they don't nicely use the equation shown before anymore), you have to do a bit of work, but it does work out.
With this, our equation to find the sum of every 3rd term with an offset of looks like the following:
Solving the Guiding Problem
Armed with this knowledge, we can know solve our guiding problem. If you need a refresher, the problem boils down to the following:
To do this, we need to find the sum of every 6th coefficient with an offset of 0 and the sum of every 6th coefficient with an offset of 3 for the polynomial
We will call the first sum and the second sum . We can apply the no offset roots of unity filter to calculate :
While we could plug this in and solve for directly, it would be incredibly difficult. However, we can proceed with calculating to see if we get any nice cancellations. We can apply our offsetted roots of unity filter to calculate . To do so, we first need to find what our coefficients will be to get our column of s to shift to , which will give us the offset of that we need.
Root of Unity | Original | Modified | |
---|---|---|---|
Note that the way we choose the coefficients is that we want the coefficient of to increase so it becomes a multiple of and the coefficient evaluates to .
Then, we can calculate as:
When we combine this with to get our total answer of , we obtain the following:
Now that our sum is greatly simplified, we can plug in and see what we can cancel out. The first thing we can notice is that as derived above, so our middle term cancels out to , so we can ignore that. The next thing we can do is calculate what is in rectangular form so that we can add the to it as part of .
To calculate this, we can use de Moivre's theorem after converting to polar form.
We can do this with as well.
Therefore, our final sum evaluates to:
Note
The original problem was part of a mock AIME and asked for the answer mod . Since this post is about roots of unity filter, we won't cover that part in depth, but to calculate the value mod , you could apply the Euler's Totient Theorem with to find that . Then, the answer is .
Final Notes
Roots of unity filter is a super useful technique on some problems, but it can involve a lot of calculations and is not applicable to everything. For our guiding problem, we were fortunate enough to have all of our complex roots of unities dissipate nicely, which is something that you will frequently see for math competition problems that use roots of unity filter. Roots of unity filter can also be especially powerful when combined with generating functions. I might write an article on generating functions later, so stay tuned for that!
Generally, most problems will use the 4th roots of unity, which makes it incredibly convenient since all of the roots of unities are either entirely imaginary or entirely real. For less convenient problems, a calculator or some other clever insight may be necessary to evaluate the result.