Evaluation and Interpolation
August 25, 20265 min readbeginner
The entire transform rests on one observation, and the observation involves no roots of unity, no modular arithmetic, and nothing more advanced than plotting points.
The entire transform rests on one observation, and the observation involves no roots of unity, no modular arithmetic, and nothing more advanced than plotting points. It is worth meeting it in that plain form first.
01.A polynomial is determined by its values
Take a polynomial of degree at most , that is, a straight line . Two numbers describe it: and .
Two other numbers also describe it. Pick any two distinct inputs, say and , and record the outputs and . Those two values pin the line down completely, because two points determine a line.
The same holds at every degree. A polynomial of degree at most has coefficients, and it is equally determined by its values at any distinct points. Going one way is evaluation. Going back is interpolation.
So there are two equally valid ways to store a polynomial.
Coefficient form. The list .
Point-value form. The list , for some agreed set of distinct points.
Neither loses information. They are two encodings of the same object.
02.Multiplication is cheap in the second form
Here is why anybody cares.
Suppose and are both stored in point-value form, at the same points. What is the point-value form of their product ?
At each point ,
That is it. One multiplication per point. The value of a product at a point is the product of the values, which is true because that is what multiplying functions means.
So in point-value form, multiplying two polynomials of any degree costs multiplications rather than . Linear, not quadratic.
Work it concretely with two lines. Let and , and evaluate at .
| 0 | 1 | 3 | 3 |
| 1 | 3 | 4 | 12 |
| 2 | 5 | 5 | 25 |
| 3 | 7 | 6 | 42 |
Check the last column against the true product, which is . At that gives . Correct. At , . Correct.
Four points were used rather than three because the product has degree and so needs three values to determine it, and taking one extra costs nothing.
03.The round trip
That suggests an algorithm immediately.
- Evaluate at points.
- Evaluate at the same points.
- Multiply the values pointwise. Cost: multiplications.
- Interpolate back to coefficient form.
Step 3 is wonderfully cheap. Steps 1, 2 and 4 are the problem.
Evaluating a polynomial with coefficients at one point costs about multiplications by Horner's method. Doing that at separate points costs , which is exactly what we were trying to avoid. Interpolation by the standard method is no better.
So the round trip as described saves nothing. The expensive part simply moved.
04.Where the saving comes from
The way out is to stop treating the evaluation points as arbitrary.
Nothing so far constrained them. Any distinct points work. That freedom is the opening: if the points are chosen with a particular relationship to one another, evaluating at all of them at once can share work, and the shared work collapses the cost from to .
The relationship that does it is this. Choose the points so that they are the powers of a single element , that is
where has the property that and no smaller positive power of equals . Such an is called a primitive th root of unity.
Why that helps is worth seeing rather than taking on trust. Split into its even-indexed and odd-indexed coefficients, writing
where each half has coefficients. To evaluate at all points, you need and at the squares of those points.
Now the special property does its work. Squaring the powers of does not give different values. It gives only , because squares to the same thing as . So the two half-sized problems are evaluated at half as many points, and the recursion halves the work at every level rather than merely splitting it.
That gives the recurrence
whose solution is . Two subproblems of half the size, plus linear work to recombine. This is the Cooley-Tukey structure, and The Butterfly and Bit Reversal writes out every step of it for .
05.One complication to flag now
There is a mismatch that has to be dealt with, and it is easier to name here than to discover later.
The construction above computes the product modulo , not modulo . The reason is direct: the evaluation points satisfy , so any multiple of evaluates to zero at every one of them and is invisible to the transform.
That is the cyclic convolution, where the coefficient that overflows past degree wraps around and is added back at the bottom.
needs the negacyclic version, where the overflow wraps around and is subtracted, because .
Fixing the mismatch requires evaluation points satisfying rather than . Those exist, and finding them is the subject of the next note.