Chapter 12 §09 built one unitary matrix, , that diagonalizes
every circulant of its size, and then counted the cost
of using it. Forming as a
matrix–vector product takes about multiplications, so
the elegant three-step recipe “transform, divide,
transform back” for a circulant system costs — better than
elimination, but not dramatically so. The section closed
by naming the way out: the powers of repeat, splitting
one transform of length into two of length
costs almost
nothing, and iterating “brings the cost down to about
”. That
algorithm is the fast Fourier
transform, and Chapter 12 handed it here,
“together with the cost accounting that makes ‘quickly’
precise”.
This section pays that debt. There is no new theorem
about here;
there is one matrix identity, proved by computing an
entry, and one recurrence, solved exactly.
Throughout, as in Chapter 12 §09, rows,
columns, and vector entries are numbered , and . We write for the Fourier
matrix of size of
Theorem 12.9.3, so
; Chapter 12 wrote it
, the size being
fixed there.
Chapter 12 §09 defined the discrete Fourier
transform of to be
, the vector of eigenvalues
of the circulant with first row . It is the
unnormalized transform that the algorithm computes, so
it is convenient to give its matrix a name of its
own.
Definition
24.12.1 (The transform matrix)
For let
so that for every .
A cost in this section is a count of
arithmetic operations, where one complex addition, one
complex subtraction, one complex multiplication, and one
complex division each count as one
operation; a multiplication by the constant
is free, because
it is not performed. What is being counted is the work
of applying to
an arbitrary vector, not the work of writing down.
Applying as
a plain matrix–vector product costs operations: each of the entries of is a sum of
products. This
figure charges every one of those products, including
the whose
factor is an entry of row
or column ; it is the plain
matrix–vector product as it is ordinarily performed, and
the comparisons below use it as it stands. For that is operations.
The whole of this section is about replacing that number
by about .
Where can a saving possibly come from? The entries of
are powers of
, and there
are only distinct
ones, so the
products involve
enormous repetition. The single algebraic fact that
organizes the repetition is Squaring a primitive -th root of unity gives
a primitive -th
root of unity. So if we separate the even-numbered
entries of
from the odd-numbered ones, the even half is transformed
by , not by
anything new. Two objects give the bookkeeping a
name.
Definition
24.12.2 (The even-odd permutation, the twiddle
matrix, and the butterfly)
Let with
.
- (a) The
even-odd permutation matrix is the
permutation matrix determined by it lists the even-numbered entries of first, then the
odd-numbered ones, each in their original order.
- (b) The
twiddle matrix is . Its entries are powers of ,
not of .
- (c) The
butterfly matrix is
In words:
is pure data movement and does no arithmetic; supplies the twiddles that the odd
half needs because it starts one place late; and forms the sums and the differences that
recombine the two halves. Applied to a vector
split into two halves of length , the butterfly returns
.
Theorem
24.12.1 (The Radix-Two Factorization)
Let with
. Then Equivalently, for the unitary Fourier
matrices,
Idea. Apply both sides to an
arbitrary
and compute entry
of the left side. Split the defining sum
into its even and odd parts; the relation
turns each part into a transform of length , and the odd part
carries one spare factor . That is the
whole computation, and it already gives the top half of
the answer. For the bottom half, write ; the relation
makes the two transforms of length repeat what they gave
at , while flips the
sign of the spare factor. Sum and difference: the
butterfly.
Proof. Let and
put so that and for , by Definition 24.12.1. By Definition 24.12.2 (a),
is
exactly the pair of these two argument vectors stacked,
so the right-hand side applied to is .
Now compute entry of . Splitting
the index into
and with , and
using ,
Top half. For the two sums are and , so the last equality by Definition 24.12.2 (b),
the -th diagonal
entry of being
.
Bottom half. For with , we have
,
since ; so both sums repeat their values at , namely and . The spare factor is
because . Hence
The two halves together say that equals the
right-hand side applied to , for every ; so
the two matrices are equal. For the second display,
substitute and and divide by , using .
The identity is a factorization of one matrix into
three, and each of the three is cheap for a different
reason: does
no arithmetic, the middle factor is two copies of a
smaller instance of the same problem,
and costs
. That is the
entire content of the fast Fourier transform. Everything
below is bookkeeping.
Solution. Here , so (it lists
then ), , and . Hence and the right-hand side is . And
, which is the same matrix.
Solution. Here and , so and
Multiplying, has rows , , , . Applying
adds row 3 to
row 1, adds times
row 4 to row 2, and so on, giving whose -entry is . Dividing by returns the
matrix written out in Example (The Fourier matrix of size four).
Warning. The twiddles are
powers of ,
not of . If
in Example (The factorization for )
is taken to be , the product becomes
the real matrix with rows , , , , whereas the
second row of
is .
The single factor in the proof
is what remembers that the odd-numbered entries start
one step later, and it is the only place where the
transform of size
differs from two transforms of size .
The cost,
exactly
Read Theorem 24.12.1 from right
to left as a procedure.
Algorithm. Input.
,
with a
power of two.
Output. .
- If ,
return .
- Split
into its even-numbered and odd-numbered entries (no
arithmetic).
- Compute and , the transforms
of the two halves, by applying this procedure to each of
them.
- Multiply: set , and for , where
.
- Return .
The procedure returns for every
, by
induction on : for
step 1
returns , and for the inductive
hypothesis makes the and of step 3 the
two transforms of length named in the proof of
Theorem 24.12.1, so steps
4 and 5 return , which
that proof identifies with . What is
left is the cost.
Theorem
24.12.2 (The Cost of the Fast Fourier
Transform)
Let be the
number of operations the procedure above performs on an
input of length , with . Then , and the solution of this recurrence is exactly
In particular .
Idea. Step 3 is where the recursion
sits and contributes ; steps 4 and 5 are
the only arithmetic outside it, and both are linear in
. Count them once,
carefully: step 4 is multiplications, the
factor at
not being applied at all, and step 5 is additions and subtractions. Then
solve the recurrence by induction on , which works because
the recursion halves the length exactly.
Proof. For the procedure
returns its input and does nothing, so .
Let with
. Step 2
only moves data. Step 3 calls the procedure twice on
length , costing
. Step 4
copies , which
is no arithmetic, and forms for , which
is
multiplications. Step 5 forms sums and differences, which is
operations.
Adding,
Now induct on .
For , the
formula gives . Let and suppose . Taking in the
recurrence, where the last line collects . This completes the induction.
Substituting , so , gives the stated formula, and for , so .
The exact formula is worth tabulating against the
of a plain
matrix–vector product.
|
|
|
|
|
|
|
|
|
|
|
|
At the
ratio is about ,
and it grows without bound, because behaves
like . This is the sense in which the transform can
be applied “quickly”: the exponent drops from to , up to a logarithm, and
the constant in front is
small.
Warning. The recursion
needs even at
every level, so is the clean case. For odd and greater than
the factorization
of Theorem 24.12.1 does not
apply at all, and the procedure above cannot start. For
with
odd, it descends
levels and then
must transform vectors of length some other way; if
is large, nothing
has been gained. The remedy is either to split by other
factors of , as in
Exercise (C1: Splitting into three),
or, for the convolution use below, to pad with zeros up
to the next power of two — which at most doubles and so changes the cost
by a bounded factor.
Example
(A transform of length eight)
Compute for by the procedure, showing
every level, and check the result against the direct
definition at one entry.
Solution. Level 1. The
even-numbered entries are and the
odd-numbered ones are .
Level 2, applied to . Its even
and odd halves are and , whose transforms
are and . Here , so and . The
butterfly gives . So .
Level 2, applied to . Its even
and odd halves are and , whose transforms
are and . Again and , so the butterfly gives . So
.
Level 1, recombination. Now and with ,
so the irrational entries of never appearing
because . The butterfly gives
Check at . By Definition 24.12.1, since . This is
matching. The zeros in the odd positions are
not an accident. Since repeats with
period , that is
,
splitting the defining sum at gives using . The factor is at every odd .
What the
speed buys
Two corollaries, both immediate now, and both paying
off Chapter 12 §09.
Chapter 12 §09 proved the Convolution Theorem:
entrywise (Theorem 12.9.6
(b)). Before this section that identity converted an
convolution
into three
transforms, which is no gain at all. With Theorem 24.12.2 it becomes
a genuine algorithm.
Corollary
24.12.3 (Convolution in )
Let . The
cyclic convolution of two vectors in can be computed in
operations, where is as in Theorem 24.12.2.
Consequently, the product of two polynomials in of degree at most
can be computed
in
operations.
Proof. The inverse
transform costs the same. By Theorem 12.9.3,
, and is symmetric because
is unchanged by swapping
and ; hence
and Conjugating the identity of Theorem 24.12.1 entry by
entry, and noting that is real, gives which is the same factorization with every
replaced
by . The procedure therefore runs
verbatim with in place of
and
computes in
operations.
The algorithm. By Theorem 12.9.6 (b)
and the definition , Computing and costs ; the entrywise products cost
; the inverse
transform costs ; the divisions by cost . The total is , and
substituting the formula of Theorem 24.12.2 gives
, as stated.
Polynomials. Let and , and choose with and , which is
possible since the powers of two are spaced by a factor
of two. Let be the coefficient vectors
padded with zeros. The coefficient of in , for , is
summed over , while with the subscript
read modulo . The
two agree: a term of the second sum with has -subscript , and it can be
nonzero only if and , which forces , contradicting . So the
coefficients of
are the first
entries of ,
computable in operations with , which is
.
Warning. Convolution wraps
around; polynomial multiplication does not.
Padding to length is not a convenience, it is the
hypothesis. Take , so , and convolve the unpadded vectors in : the answer is
, the coefficient vector of
, whereas
. The term has wrapped
around onto the constant term, because in the exponents are
read modulo and
.
Padding to in gives , which is
right.
Corollary
24.12.4 (Solving a Circulant System in )
Let , let
be
an invertible circulant with first row , and let . Then
the solution of can be computed in
operations.
Proof. By Theorem 12.9.4,
with , and the
diagonal of is exactly ; the letter is reserved here for
the twiddle matrix of Definition 24.12.2. Since
is invertible,
every by Corollary 12.9.5
(d), so exists and
where is entrywise
division and the last equality uses and
, as in the proof of Corollary 24.12.3. The
three transforms cost each, by Theorem 24.12.2 and the
first part of that proof; the divisions and the final scalings by cost . Sanity check at : then ,
, and the formula returns , using .
Exercises
A. Check your
understanding
Solution.
(a) ,
with for and
(Definition 24.12.1). It is
the matrix of the discrete Fourier transform of Chapter 12 §09.
(b) for . Applying costs nothing, since
it only moves entries; the middle factor costs two
transforms of length ; and costs multiplications and
additions and
subtractions.
(c) Directly:
multiplications
and
additions, that is . By the algorithm: (Theorem 24.12.2).
(d) False. Theorem 24.12.1 is an
identity between matrices, so the algorithm returns
exactly, in exact arithmetic. It is faster because it
applies the same matrix by a cheaper route, not because
it computes something else.
(e) The
factorization needs , and the recursion needs that at every
level, so it needs . For other one either pads with
zeros to the next power of two, which is legitimate for
convolution provided the padded length still exceeds the
degree of the product (see the warning after Corollary 24.12.3), or
splits by a different factor of , as in Exercise (C1: Splitting into three).
B. Practice
Solution.
(a) The
even-numbered entries are and the
odd-numbered ones are . Both transform to
, so . With , , so . The butterfly gives
(b) The symbol is
(Definition 12.9.1),
and . Then ; , using and ; ; and . The four values agree with (a).
(c) Each costs operations (one sum,
one difference), so the two halves cost ; the twiddles cost
, since the factor
is free and only
is a
multiplication; the final butterfly costs . The total is , and . A direct matrix–vector product would
cost .
Solution. Level 1.
Even-numbered entries ; odd-numbered entries .
Level 2 on . Halves
and , with transforms
and . Here the inner
is , so and
.
The butterfly gives .
Level 2 on . Halves
and , with transforms
and ; ; the
butterfly gives .
Level 1, recombination. Now and , so . Hence
Check at . Since , Definition 24.12.1 gives
, as computed.
Solution.
(a) The product
has degree , so coefficients are needed
and any
works; the smallest power of two is . The padded vectors
are and .
(b) With
subscripts modulo
and , , , the sum
keeps only and , so : Hence , which one checks by expanding:
.
(c) Length holds and but not the four
coefficients of ,
and although is
not a power of two it shows the wrap plainly: with , , and
subscripts modulo , which is with the coefficient
of added onto the
constant term, since modulo . The requirement in Corollary 24.12.3 is
exactly what rules this out.
C. Going deeper
Solution.
(a) Write with and , which
lists each exactly once. Then, using , Put . Since , we get
, so the inner sum is by Definition 24.12.1. And
, so Substituting gives the stated
formula.
(b) The procedure
is: split
by the remainder of the index modulo (no arithmetic);
transform the three parts recursively, getting ; multiply by for and all ; and for each apply to the resulting
triple, placing the three outputs at positions , , and . Correctness is
(a).
Cost. The recursive calls cost . The twiddles are
multiplications,
the factors for being .
Each three-point transform costs at most multiplications and
additions, that
is operations,
and there are of
them. Hence .
Now put . The inequality with reads , that is .
Since , induction gives , so .
With , that
is .
Solution.
(a) By Definition 24.12.1 and the
definition of the matrix product, Put , so . If divides , then and the sum is
. Otherwise by Example (Roots of Unity),
and the geometric-series identity used in the proof of Theorem 12.9.3
gives , since . So exactly when and
otherwise, which
is .
(b) The map modulo is its own inverse, so
and
. Since , we get , so
.
Hence
annihilates ;
if with ,
then , so and by Example (Roots of Unity).
(c) From (a),
, so . Its -entry is times entry
of , namely , using and
. That is the -entry of .