Module 30 of 39

Polynomial multiplication, convolution, and the FFT

See convolution as coefficient work and the FFT as a fast change of representation.

A polynomial can be stored by its coefficients. For example, 1 + 2x is the list [1, 2]: the constant coefficient is 1 and the coefficient of x is 2. Multiplying (1 + x)(1 + 2x) gives 1 + 3x + 2x². The coefficient 3 comes from two products, 1·2 and 1·1, whose degrees add to 1.

Background for this page. You need polynomial coefficients, powers, and the idea of evaluating a function at a number. Complex roots of unity are needed for the full FFT derivation; the representation change can be understood before that derivation. Related explanations: Divide and conquer: merge sort and recurrences · Matrices: dimensions, products, and transposes.

In general, each output coefficient is a sum of products of input coefficients whose positions add to the output position. This is a convolution. The direct method examines many pairs of coefficients and takes Θ(n²) time for two length-n lists.

Two coefficient lists multiply; two products contribute to the coefficient of x.

There is another representation. Instead of storing a polynomial by its coefficients, we can store its values at chosen points. If we know the values of two polynomials at a point, we can multiply those values to get the product’s value there. That part is easy. The expensive question is how to move quickly between coefficients and enough point values to recover the product.

The discrete Fourier transform (DFT) chooses special complex-number points called roots of unity. Their structure lets the fast Fourier transform (FFT) evaluate at those points, or interpolate back from them, in Θ(n log n) time. The method splits the coefficient sequence into even and odd positions, solves smaller transforms, and combines them. With enough points to avoid losing coefficients, polynomial multiplication becomes: transform both inputs, multiply values point by point, then use an inverse transform. The overall growth is Θ(n log n).

# Leave room for every coefficient in the product.
pad both coefficient lists to a suitable length
# Change from coefficients to values at special points.
transform both lists with the FFT
# Multiplication is easy in the value representation.
multiply the matching transformed values
# Recover the product's coefficients.
apply the inverse FFT

The same mathematics appears in signal processing, where a time-based signal is represented by frequency components. In real software, numerical precision and padding choices matter. Floating-point FFT results may contain small rounding errors; exact integer convolution may use other techniques or careful rounding with proven bounds. The algorithmic idea is a change of representation that makes the central operation cheap.

Count the output positions before transforming

Two coefficient lists of lengths a and b represent degrees at most a−1 and b−1. Their product has degree at most a+b−2, so it needs a+b−1 coefficient positions. For [1,1] and [1,2], that means three positions, holding [1,3,2]. A radix-two FFT commonly pads to the next power of two, four in this example.

Too little padding computes a circular convolution: contributions wrap around and add into earlier positions. That differs from the ordinary polynomial product. Padding is therefore part of correctness, not just a performance preference.

The Θ(n log n) statement counts arithmetic operations on transform values under the usual model. Exact bit complexity and floating-point error need separate analysis. This lesson introduces the method; it does not derive the roots-of-unity identities or implement a reliable numerical FFT.

Practice. Multiply (1 + x)(1 + 2x) by hand. Why can we not transform two length-n coefficient lists with too few output positions and expect the full product back?

Answer. The product is 1 + 3x + 2x². Two degree-1 polynomials produce a degree-2 result. Too few positions make distinct output coefficients overlap or disappear, so the inverse transform cannot recover the full product.

Try another case. How many product coefficients can two length-four lists require, and what radix-two transform length suffices?

Reasoning. They can require seven coefficients. A transform length of eight supplies enough space.

View the full course and choose another topic.

Image preview

Fit