A polynomial A(x) can be written in the following form:
The degree of A is n-1;
First, consider the different representations of polynomials, and the time necessary to complete operations based on the representation.
The runtimes for the representations and the operations are described in the table below, with algorithms for the operations versus the representations.
We combine the best of each representation by converting between coefficients and samples in O(n log n) time.
How? Consider the polynomial in matrix form.
where V is the Vandermonde matrix with entries vjk = xj^k .
Then we can convert between coefficients and samples using the matrix-vector product V · A, which is equivalent to evaluation. This takes O(n2).
Similarly, we can samples to coefficients by solving V \Y (in MATLAB®notation). This takes O(n3) via Gaussian elimination, or O(n2) to compute A = V −1 · Y if V −1 is precomputed.
To do better than Θ(n2) when converting between coefficients and samples, and vice versa, we need to choose special values for x0, x1,...,xn−1. Thus far, we have only made the assumption that the xi values are distinct.
We can formulate polynomial multiplication as a divide and conquer algorithm with the following steps for a polynomial A(x) ∀ x ∈ X.
We can do better if X is collapsing: either |X| = 1 (base case), or |X2| = |X| and 2 X2 is (recursively) collapsing
Collapsing sets can be constructed via square roots. Each of the following collapsing sets is computing by taking all square roots of the previous set.
We can take advantage of the nth roots of unity to improve the runtime of our polynomial multiplication algorithm. The basis for the algorithm is called the Discrete Fourier Transform (DFT).
The DFT allows the transformation between coefficients and samples, computing A → A∗ = V · A for xk = eiτ k/n where n = 2£ , where A is the set of coefficients and A∗ ∗ n−1 iτ jk/n is the resulting samples.
Fast Polynomial Multiplication
In order to compute the product of two polynomials A and B, we can perform the following steps.