At the beginning of this series, we argued that the multiplication of two polynomials of degree at most can be performed in complexity time if both polynomials are in point-value form.
In practice, the difficulty is that polynomials are usually given in coefficient form, and we want the result of the multiplication to also be in coefficient form.
Fortunately, these problems can be solved by using the fast versions of the NTT and INTT.
To multiply two polynomials represented in coefficient form in time, the procedure is as follows:
- Using the NTT, the polynomials are converted from coefficient form to point-value form.
- The polynomials in point-value form are multiplied pointwise. This can be performed in time complexity , and the result is obtained in point-value form.
- The INTT is used to transform the resulting polynomial back to coefficient form.
Using -th roots of unity, where is a power of , steps 1 and 3 can be performed in time.
The only limitation is that we must impose a maximum degree of on the resulting polynomial. Therefore, the sum of the degrees of the two polynomials we want to multiply cannot exceed .
In practice, this is generally not a problem, since we can usually use fields containing sufficiently large -th roots of unity so that the degrees of the polynomials remain within the allowed bound.
Polynomials of degree less than do not represent a problem, since they can be padded with zero-valued coefficients up to degree .
Without using the fast NTT and INTT, polynomial multiplication would have time complexity .
The aim of this chapter is to prove our claim. We will show that multiplying two polynomials in coefficient form is equivalent to applying the NTT to each polynomial, performing pointwise multiplication, and then applying the INTT to the resulting polynomial obtained from this operation.
This result is known as the convolution theorem in the context of polynomial multiplication. In a more general context, the convolution theorem states that
“convolution in the original domain is equivalent to pointwise multiplication in the transformed domain.”
To properly understand this theorem, we need to start by defining what convolution is.
Readers less inclined toward mathematics can skip this chapter without loss of continuity. In the rest of the text, we prove the convolution theorem, but if the reader is only interested in its application, it is sufficient to accept that it can be used to multiply polynomials in time complexity instead of .
Convolution
Multiplying two polynomials in coefficient form is an example of a convolution operation.
Consider two polynomials of degree 2,
and
Multiplication in coefficient form yields the polynomial
Rearranging this expression, we obtain
Thus, the coefficients of the polynomial resulting from the multiplication of and are
These coefficients can be compactly expressed by the formula
for , which is the degree of the polynomial . Let us examine this for one of the coefficients, . For this coefficient, we have
Since both and are zero (because the polynomials and have degree 2), this reduces to
as expected.
The operation defined by
is called a convolution and is usually written as
where denotes the convolution operator.
The Convolution Theorem
Our goal is to prove that converting and to point-value form, multiplying the corresponding points, and converting the result back to coefficient form is equivalent to performing the convolution of the coefficients of and .
Consider the polynomials
and
of degree and .
Multiplying and produces a new polynomial whose degree is the sum of the degrees and of and , respectively.
Suppose that the degree of is .
Thus, we want to compute
If the degree is less than , we can pad the coefficients of the higher-degree terms with zeros.
Let us represent the coefficients of the polynomials and as
Some of the higher-degree coefficients above will be zero, as the degrees of and must sum to at most . This is not a problem. Our only restriction is that
Our first step is to convert the polynomials and from coefficient form to point-value form.
First step: convert the polynomials to point-value form.
To convert these polynomials to point-value form, we use the NTT. By choosing to be a power of , we can apply the fast transform. However, since the final result is equivalent to multiplication by the Vandermonde matrix, we will present the matrix formulation.
For instance, for the polynomial , its evaluations at the -th roots of unity are given by
Similarly, for ,
These matrix operations can be written componentwise as
and
For example, the evaluation of is given by
Second step: perform pointwise multiplication of the polynomials in point-value form.
We now multiply the evaluations of and pointwise to obtain the evaluations of the product polynomial :
In index notation, this can be written as
Using the expressions for and obtained in the previous step, we obtain
To recap, what we want to show is that if we perform the INTT on the polynomial in its point-value form (the above form), the result is the same as performing the convolution of and .
Last step: apply the INTT to the polynomial in point-value form
The Inverse Number Theoretic Transform over the -th roots of unity is performed using the Vandermonde matrix scaled by a factor of .
Thus, by applying the INTT to the set of points , we obtain the polynomial in coefficient form:
This can be written component-wise as
Using the fact that is given by
we have that
This expression is large, but it can be simplified by applying the orthogonality property of the roots of unity.
First, let us group all powers of :
The expression above indicates that we can use the orthogonality of the roots of unity to simplify it.
Recall that the orthogonality property of the roots of unity is given by
Using the above formula for the isolated sum of roots of unity in , we note that
is equal to if (or equivalently ), and zero otherwise.
This can be represented as multiplied by the Kronecker delta:
Replacing
in the expression for , we have that
The constants and cancel out:
More importantly, when summing over the index , all terms vanish except when . This is due to the orthogonality of the roots of unity.
As a result, the summation over collapses, and we can replace the summation in with the single element . We obtain
This is exactly the convolution formula!
Let us recall what we did:
- We applied the NTT to the polynomials and , converting their coefficient representations into point-value representations, that is, vectors containing their evaluations at the -th roots of unity:
- We multiplied these evaluation values pointwise, meaning that for each root of unity we computed
obtaining the point-value representation of the product polynomial .
- We applied the INTT to this vector of values
to recover the coefficient representation of .
We showed that these three steps produce exactly the same result as multiplying the polynomials and , namely, convolving the coefficients of and .
However, while direct convolution has time complexity , the procedure above can be executed in time, yielding the same final polynomial.
This is exactly what the convolution theorem states. In a more formal way, we can write it as follows:
Let and be two polynomials in their coefficient form. Let denote the convolution operation and denote multiplication.
Let denote the application of the NTT to — that is, while is the vector of coefficients, is the vector of evaluations — and denote the application of the INTT to . Then,
Another way to express the convolution theorem is
This is a linear transformation, and it can be understood as follows: convolution in the coefficient domain is equivalent to pointwise multiplication in the point-value domain.
This article is part of a series on the Number Theoretic Transform in our ZK Book