Butterfly diagram
From Wikipedia, the free encyclopedia
In the context of fast Fourier transform algorithms, a butterfly is a portion of the computation that combines the results of smaller discrete Fourier transforms (DFTs) into a larger DFT, or vice versa (breaking a larger DFT up into subtransforms). The name "butterfly" comes from the shape of the data-flow diagram in the radix-2 case, as described below. The same structure can also be found in the Viterbi algorithm, used for finding the most likely sequence of hidden states.
Most commonly, the term "butterfly" appears in the context of the Cooley-Tukey FFT algorithm, which recursively breaks down a DFT of composite size n = rm into r smaller transforms of size m where r is the "radix" of the transform. These smaller DFTs are then combined with a size-r butterflies, which themselves are DFTs of size r (performed m times on corresponding outputs of the sub-transforms) pre-multiplied by roots of unity (known as twiddle factors). (This is the "decimation in time" case; one can also perform the steps in reverse, known as "decimation in frequency", where the butterflies comes first and are post-multiplied by twiddle factors. See also the Cooley-Tukey FFT article.)
[edit] Radix-2 butterfly diagram
In the case of the radix-2 Cooley-Tukey algorithm, the butterfly is simply a DFT of size 2 that takes two inputs (x0,x1) (corresponding outputs of the two sub-transforms) and gives two outputs (y0,y1) by the formula (not including twiddle factors):
- y0 = x0 + x1
- y1 = x0 − x1
If one draws the data-flow diagram for this pair of operations, the (x0,x1) to (y0,y1) lines cross and resemble the wings of a butterfly, hence the name. (See also the illustration at right.)
More generally, a DFT on n = 2p inputs with respect to a primitive n-th root of unity
relies on O(nlogn) butterflies of the form:
- y0 = x0 + x1ωi
- y1 = x0 − x1ωi
Whereas the inverse transform with respect can mathematically be interpreted as a direct transform with respect to ω − 1, one may also directly invert the butterflies:
Recently, it was noticed by Joris van der Hoeven that the pair (x0,y1) is also related to the pair (x1,y0) by simple formulas:
- x0 = y0 − x1ω
- y1 = y0 − 2x1ω
and
- x1 = (x0 − y1)ω − 1
- y0 = 2x0 − y1
These "flip"-relations are at the basis of a truncated version of the DFT.



