As seen in the previous article, the Inverse Number Theoretic Transform (INTT) is performed using a Vandermonde matrix, just like the NTT. This shows that both evaluation via the NTT and interpolation via the INTT are similar operations.
The problem with directly using the Vandermonde matrix for evaluation or interpolation is that multiplying a k×k matrix by a vector takes O(k2) time. Fortunately, when using the k-th roots of unity, with k a power of 2, a fast method that does not rely on matrix multiplication can be used, reducing the time complexity to O(klogk).
The fast method for the NTT was introduced in the chapter “NTT Algorithm by Hand.” In this chapter, we study the fast method for the INTT.
The idea is simple: to interpret polynomial interpolation as an evaluation, allowing the use of the same method employed for the NTT.
Evaluation and Interpolation
As a recap, the NTT allows us to transform a polynomial of degree at most k−1 from its coefficient form,
a0a1...ak−1
to its point-value form,
f(ω0)f(ω1)...f(ωk−1)
by evaluating the polynomial at the k-th roots of unity. This is called evaluation.
Interpolation is the opposite of evaluation: it is the process of transforming a polynomial from its point-value form to its coefficient form.
Interpolation as evaluation
Evaluations and interpolations at the k-th roots of unity are similar operations because both are performed using a Vandermonde matrix.
For better visualization, consider a polynomial of degree at most 3,
Inspired by the evaluation structure, we can view 4f(1),4f(ω),4f(ω2) and 4f(ω3) as the coefficients of a new polynomial f~(x), defined as
f~(x)=41(f(1)+f(ω)x+f(ω2)x2+f(ω3)x3).
In this terms, the coefficients a,b,c and d are the evaluations of f~(x) at the following points:
abcd=f~(1)=f~(ω−1)=f~(ω−2)=f~(ω−3)
Therefore, we can interpret interpolation as the evaluation of another polynomial. The crucial observation is that the inverse NTT does not require a fundamentally different algorithm.
Once the point-value representation is reinterpreted as the coefficient vector of a new polynomial, interpolation becomes an evaluation at a permuted set of roots of unity. In this sense, evaluation and interpolation are the same operation.
Avoiding working with inverses of the roots of unity
A polynomial of degree at most k−1, where k is a power of 2, can be evaluated at the k-th roots of unity using the fast method explained in the chapter NTT Algorithm by Hand.
The evaluations of
f~(x)=41(f(1)+f(ω)x+f(ω2)x2+f(ω3)x3)
at the points f~(1),f~(−1),f~(ω) and f~(−ω) are illustrated below.
The idea is to group the even and odd powers as
f~(x)=41(f(1)+f(ω2)x2)+x(f(ω)+f(ω3)x2)),
and evaluate f~(x) at 1. At each evaluation of an innermost square root, the expression branches into two, one for each value of the square root. This continues until no square roots remain, at which point the procedure ends.