Multiplication and Fast Fourier Transforms
Overview
Kent Quanrud develops divide-and-conquer multiplication from the grade-school O(n²) method to Karatsuba’s three half-size multiplications, yielding O(n^log₂3), or about O(n^1.585), time. He then explains the Fast Fourier Transform (FFT) as an O(n log n) method for evaluating polynomials at roots of unity, using it to multiply polynomials quickly, before introducing Strassen’s seven-multiplication matrix algorithm and the still-open goal of O(n²) matrix multiplication.
Key takeaways
- Karatsuba’s identity reduces integer multiplication from four recursive half-size products to three, changing the running time from O(n²) to O(n^1.585).
- The FFT evaluates a polynomial at roots of unity by recursively splitting its coefficients into even and odd indices, achieving O(n log n) time.
- Polynomial multiplication is accelerated by transforming both inputs, multiplying their values pointwise at 2n roots of unity, and applying the inverse transform.
- Strassen’s seven half-size matrix multiplications yield an exponent of log₂7, approximately 2.807, instead of the standard cubic exponent.
- The improvements in Karatsuba, FFT, and Strassen come from changing the representation or algebraic organization of a problem, not merely optimizing the original computation.
Chapters
- Two n-bit integers can produce a product of up to 2n bits.
- The grade-school method combines each digit of one number with each digit of the other, requiring O(n²) work.
- Kent Quanrud frames the central question: can multiplication beat the quadratic algorithm?
- Bit shifts still require work proportional to the number of bits being moved.
- Splitting the inputs is proposed as a divide-and-conquer strategy, but the pieces must be recombined efficiently.
- Factoring the inputs is not a practical shortcut; factoring is difficult and underlies RSA.
- Write x = x₁·2^(n/2) + x₂ and y = y₁·2^(n/2) + y₂.
- Expanding xy produces four subproducts: x₁y₁, x₁y₂, x₂y₁, and x₂y₂.
- Four recursive multiplications of n/2-bit values satisfy T(n) = 4T(n/2) + O(n), which remains O(n²).
- The straightforward split still performs four recursive multiplications, so it does not improve the asymptotic running time.
- The key opportunity is the middle cross-term, x₁y₂ + x₂y₁.
- Quanrud prompts the class to find a way to recover that cross-term with only one additional recursive product.
- Compute (x₁ + x₂)(y₁ + y₂), which equals x₁y₁ + x₁y₂ + x₂y₁ + x₂y₂.
- Subtract the already-computed products x₁y₁ and x₂y₂ to obtain both cross-terms together.
- Recombine as x₁y₁·2^n + (x₁y₂ + x₂y₁)·2^(n/2) + x₂y₂.
- Three recursive calls on n/2-bit inputs give T(n) = 3T(n/2) + O(n).
- The recursion-tree work grows geometrically, producing O(n^log₂3), approximately O(n^1.585).
- Quanrud connects the breakthrough to Anatoly Karatsuba and the mid-century challenge associated with Andrey Kolmogorov.
- A complex number has the form a + bi, with i² = −1; multiplication follows the usual distributive rules.
- Euler’s formula, e^(iθ) = cos θ + i sin θ, represents points on the unit circle.
- The circular interpretation of complex exponentials helps explain their usefulness for periodic signals and Fourier methods.
- An nth root of unity is a complex number whose nth power equals 1.
- The values e^(2πik/n), for k from 0 to n−1, evenly space the n roots around the unit circle.
- For example, the fourth roots include 1, i, −1, and −i.
- Interpret n complex inputs a₀ through aₙ₋₁ as coefficients of a degree-(n−1) polynomial.
- The discrete Fourier transform evaluates that polynomial at the n roots of unity.
- The inverse transform recovers the original coefficients, up to a factor of n under the convention used in the lecture.
- Directly computing polynomial-product coefficients uses convolution and takes O(n²) work.
- Evaluate both input polynomials at 2n roots of unity, multiply corresponding values, then apply the inverse transform.
- The 2n evaluation points provide enough values to recover the full product polynomial without losing its highest-degree coefficients.
- A fast transform computes the required evaluations in O(n log n), rather than evaluating each point independently in O(n²).
- Pointwise products take O(n) additional work, and the inverse transform returns the product coefficients.
- The transform is useful because its special roots-of-unity structure supports both fast evaluation and efficient inversion.
- Split the polynomial coefficients into even-indexed terms a₀, a₂, a₄, … and odd-indexed terms a₁, a₃, a₅, ….
- Each group forms a polynomial with half as many coefficients, suitable for a recursive transform.
- The split uses coefficient parity rather than dividing the coefficient array into its first and second halves.
- Squaring the 2n roots of unity yields the n roots of unity needed for the half-size transforms.
- The even and odd transform results are combined, with the odd results multiplied by the corresponding root-of-unity factor.
- Two recursive half-size transforms plus O(n) combination work give T(n) = 2T(n/2) + O(n) = O(n log n).
- For two n×n matrices, the standard row-by-column algorithm takes O(n³) arithmetic operations.
- Splitting each matrix into four blocks yields eight submatrix multiplications of size n/2.
- The recurrence T(n) = 8T(n/2) + O(n²) reproduces cubic running time.
- Strassen’s 1969 method combines block sums and differences to compute the result using seven, rather than eight, half-size matrix multiplications.
- Its recurrence gives O(n^log₂7), approximately O(n^2.807), improving on the conventional O(n³) method.
- The lecture closes with the open question of whether matrix multiplication can reach O(n²), despite decades of increasingly complex exponent improvements.
Transcript excerpt
0:05 All right, off we go. So, today we're doing uh two actually uh it's still divide and conquer, but it's going to be a little more kind of algebraic in field today. Uh the first problem is going to be just multiplying integers and the other one is going to be something called the fastforier transform. Um which sounds kind of fancy, but hopefully we can just break down what we need out of it. Okay. So, all right. So, here's the um a very simple problem that we're going to look at today. To start, uh I'm going to give you two integers, you know, represented as bits, right? So, they're bit strings as n bits or something. So, so two n bit integers and all you want to do is multiply them together, which means you might need two n bits. Okay? So like uh for example uh how did
0:54 we learn how to multiply in grade school assuming they still teach you how to multiply? >> Yeah. So something like uh I don't know 8 * 4 is I guess like 32 and I guess you carry like the three or something. 24 27 2 16 8 1 something like this. And the next row would be something like 7 * 4 is 28 carry a 2. 7 * 3 is 21. So it's 23 carry a two 14 16 you carry a one something like this. And uh you'll do it for I guess two more rows, right? Um, now this is just four digits, but it
1:43 could have been n. How long does it take as a function of uh n? Oh, we heard you're going to be late. >> Yeah. Yeah. >> No, thank you. >> Enjoy your Jolly Rancher. >> Huh? It'll take n squ, right? Because
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Kent Quanrud.