Complex Matrices; Fast Fourier Transform
Complex numbers have slipped into the course through eigenvalues, so once and for all this lecture makes the change to complex vectors and matrices. One rule governs everything, whenever you transpose, you also conjugate. That gives the right length, the right inner product, Hermitian matrices, and unitary matrices. Then the most important complex matrix of all, the Fourier matrix, and the factorization behind the FFT that cuts n squared multiplications down to n log n.
Why complex numbers, and the one rule to remember
Complex numbers have slipped into this course already: even a real matrix can have complex eigenvalues, and with them complex eigenvectors. Most of what remains about eigenvalues will be real, but at some point we have to face the question squarely — what changes when the vectors are complex, when the matrices are complex? What is the dot product of two complex vectors?
The answer to every one of those questions is the same small change, and it’s the message of the first half of this lecture: whenever we transpose, we also take complex conjugates.
The second half is the payoff — the most important complex matrix there is, the Fourier matrix, and the idea everyone calls the FFT. The fast Fourier transform is running “in a thousand places” as we speak; it transformed whole industries. And it turns out to be nothing more than a simple matrix factorization — one that cuts the cost of multiplying by an matrix from down to .
Length and inner product in complex space
Take a vector with components — complex numbers now, so lives in , complex -dimensional space, instead of .
What’s its length? The old recipe, , is no good. Length squared should be positive, and Strang’s two-component example shows the old recipe failing: take in . Then
but that vector certainly doesn’t have length zero. What we really want in each slot is — conjugate times the number — because , the modulus squared, which is what a length ought to be built from. If , then : exactly right. So the correct length squared is
For : conjugate to get , multiply, and get . Length — not the zero the unconjugated formula gave.
The inner product definition is forced on us: once the length is , the inner product has to match it.
Hermitian and unitary: the complex dictionary
Two more words need updating — the book gives a little dictionary translating between the real case, , and the complex case, .
Symmetric becomes Hermitian. For real matrices, symmetry means . That’s no good if is complex; the right complex version is: flip across the diagonal and take conjugates. A matrix with is called a Hermitian matrix. On the diagonal, the entries had better be real — flipping leaves them in place, so conjugating must leave them alone. Off the diagonal, entries pair up as conjugates:
is Hermitian: the above the diagonal must meet a below it. These matrices are the complex heirs of symmetric matrices, and they inherit the good properties: real eigenvalues and perpendicular eigenvectors.
Orthogonal becomes unitary. But what does perpendicular mean now? For an orthonormal basis , the test used to be ; now we must conjugate too:
— right angles measured in complex -dimensional space, unit lengths measured with the conjugate. Put those columns into a matrix and the matrix statement, which used to be , becomes . A square matrix with orthonormal columns in this complex sense gets a new name: a unitary matrix — just like an orthogonal matrix, with the word signaling that the entries may be complex.
The Fourier matrix
Now the substance: the most famous complex matrix, one of these unitary-type matrices with orthogonal columns, named after Fourier because it is the Fourier transform. For this half hour Strang moves “from the math department to EE” — electrical engineers start counting at zero, and for this matrix they’re probably right. So rows and columns are numbered through , and the entries could not be simpler:
the exponent is the row number times the column number. Column zero is all ones (); column one holds the powers ; column two holds the powers of ; and so on. Every entry is a power of one special number — none are zero, this is a full matrix, and it’s symmetric (in the old, not-quite-perfect sense, since these entries are complex).
What is ? It’s the number whose -th power is one:
But forget the rectangular coordinates — “it’s never good to work with the real and imaginary parts when we’re taking powers.” In the exponential form, the tenth power is instantly . Geometrically sits on the unit circle, one -th of the full way around. For it’s at , and its powers march around the circle — at , then , , , and coming back to : the six sixth roots of one, with the primitive one.
Orthogonal columns make the inverse easy
Why is this matrix so remarkable? First: its columns are orthogonal — but only if you remember to conjugate. Try columns one and three of (in EE counting): and . Without conjugating, the products are — four ones, not zero, and the columns look anything but perpendicular. Nevertheless they are orthogonal. Conjugate the first vector — the becomes , the becomes — and the inner product is . Right angles in the complex sense.
The columns aren’t quite orthonormal — each has length squared , so length — but divide by and has genuinely orthonormal columns. Then, exactly like an orthogonal matrix, the inverse is immediate:
So anything good we learn about , we know a similar fact about its inverse. Fourier knew that. What Fourier didn’t notice — Gauss noticed it but didn’t make a point of it — is that this matrix is so special it can be broken into pieces with lots of zeros, so that multiplying by it, or by its inverse, becomes very, very fast.
The fast Fourier transform
Here is the idea. has a neat connection to , half as big ( to , to — same story). The link is in the ‘s: the for is , one 64th of the way around the circle; square it — double the angle — and you get , exactly the for . That’s the hope, and here’s the factorization that realizes it:
Read it right to left. is a simple odd–even permutation matrix: it takes the even-numbered components of the vector first — — and then the odds — That’s hard-wired in the computer, essentially instantaneous. The middle matrix does a size-32 Fourier transform separately on the even part and the odd part; its two big zero blocks are the key, because half the matrix costs nothing. The left matrix puts the pieces back together, and its only real content is , the diagonal matrix
powers of . Multiplying by costs nothing; multiplying by the diagonal costs just 32 multiplications. So the count drops from to
But why stop? Recursion is the key word. Each breaks into two copies of with its own -and- fix-up and its own size-32 odd–even permutation. The stacked permutations sort the vector into even-evens (), even-odds (), odd-evens, and odd-odds — four pieces that get multiplied separately by . The gives way to , plus the original 32. Keep going: the transforms in the middle shrink to two-point, then one-point transforms — the count in the middle “goes down to zip” — while cheap factors pile up on both sides: permutations on the right, ‘s and ‘s on the left. From 64 to 32 to 16 to 8 to 4 to 2 to 1 is six steps — — and each fix-up level costs about 32 multiplications, so the final count is : that is, times .
Feel the difference at a typical size, . Then is over a million — . The new count is . The calculation shrinks by a factor of about 200, just from factoring the matrix properly: 200 Fourier transforms where before we could do one — and in real scientific computing, Fourier transforms are happening all the time.
And notice what the whole thing hinged on: a special matrix with orthonormal columns. Next lecture it’s back to real numbers, and to the matrices you see most in applications — positive definite matrices.
Problems
Work these with the one rule in hand — transpose means conjugate-transpose.
Let and in .
(a) Compute and , and explain which one is the true length squared.
(b) Compute the inner product .
Show solution
(a) Without conjugating: — a complex number, which cannot be a length squared. With conjugating:
The true length squared is , so . Length squared must be a positive real number, and only the Hermitian form guarantees that.
(b) Conjugate first: . Then
The inner product of two complex vectors is usually complex — that’s expected.
For which values of , , is
a Hermitian matrix? For your answer, verify that is real for when , .
Show solution
Hermitian means : the diagonal entries must equal their own conjugates, so and must be real (any real numbers), and the off-diagonal entries must be conjugates of each other, so .
Check with , , : first
Then — real, as it must be for a Hermitian matrix.
Write down for and use it to build . Then verify that columns and (EE counting: the columns and ) are orthogonal, and use orthogonality to write down .
Show solution
, so gives
Orthogonality of columns 1 and 2 — conjugate the first: , then
Each column has length squared , so , giving and
The inverse transform is just the conjugate transform, scaled — replace by and divide by .
(a) Using the factorization of into two copies of plus a diagonal fix-up of size , write the multiplication count for one level of the recursion when .
(b) The full FFT costs multiplications. For , compare this with and give the speedup factor.
Show solution
(a) One level replaces the multiplications by two transforms of size 8 plus a diagonal with 8 entries:
Already nearly a factor of 2, and the recursion keeps going on each .
(b) Direct: . FFT: . The speedup is
About 680 Fourier transforms for the price of one — the same effect as Strang’s factor of 200 at , but larger because the gap widens as grows.
Let , the primitive sixth root of one. (a) Locate on the unit circle by their angles. (b) Show that is the number that would serve as the "" for . (c) Compute and explain what this says about the columns of .
Show solution
(a) is at ; the powers double, triple, … the angle: at , at (that’s ), at , at , and back at , equal to . Six equally spaced points — the six sixth roots of one.
(b) Squaring doubles the angle: , which is one third of the way around — exactly the primitive cube root of one that builds . This is the connection (, here in the form) that powers the FFT recursion.
(c) The sum is a geometric series: . (Geometrically, six equally spaced unit vectors balance out.) But this sum is precisely the inner product of column 0 of (all ones, its own conjugate) with column 1 (the powers of ) — so it verifies that those two columns of the Fourier matrix are orthogonal.