<s>
In	O
the	O
context	O
of	O
fast	O
Fourier	O
transform	O
algorithms	O
,	O
a	O
butterfly	B-Application
is	O
a	O
portion	O
of	O
the	O
computation	O
that	O
combines	O
the	O
results	O
of	O
smaller	O
discrete	B-Algorithm
Fourier	I-Algorithm
transforms	I-Algorithm
(	O
DFTs	O
)	O
into	O
a	O
larger	O
DFT	O
,	O
or	O
vice	O
versa	O
(	O
breaking	O
a	O
larger	O
DFT	O
up	O
into	O
subtransforms	O
)	O
.	O
</s>
<s>
The	O
name	O
"	O
butterfly	B-Application
"	O
comes	O
from	O
the	O
shape	O
of	O
the	O
data-flow	O
diagram	O
in	O
the	O
radix-2	O
case	O
,	O
as	O
described	O
below	O
.	O
</s>
<s>
The	O
same	O
structure	O
can	O
also	O
be	O
found	O
in	O
the	O
Viterbi	B-Algorithm
algorithm	I-Algorithm
,	O
used	O
for	O
finding	O
the	O
most	O
likely	O
sequence	O
of	O
hidden	O
states	O
.	O
</s>
<s>
Most	O
commonly	O
,	O
the	O
term	O
"	O
butterfly	B-Application
"	O
appears	O
in	O
the	O
context	O
of	O
the	O
Cooley	B-Algorithm
–	I-Algorithm
Tukey	I-Algorithm
FFT	I-Algorithm
algorithm	I-Algorithm
,	O
which	O
recursively	O
breaks	O
down	O
a	O
DFT	O
of	O
composite	O
size	O
n	O
=	O
rm	O
into	O
r	O
smaller	O
transforms	O
of	O
size	O
m	O
where	O
r	O
is	O
the	O
"	O
radix	O
"	O
of	O
the	O
transform	O
.	O
</s>
<s>
These	O
smaller	O
DFTs	O
are	O
then	O
combined	O
via	O
size-r	O
butterflies	B-Application
,	O
which	O
themselves	O
are	O
DFTs	O
of	O
size	O
r	O
(	O
performed	O
m	O
times	O
on	O
corresponding	O
outputs	O
of	O
the	O
sub-transforms	O
)	O
pre-multiplied	O
by	O
roots	O
of	O
unity	O
(	O
known	O
as	O
twiddle	O
factors	O
)	O
.	O
</s>
<s>
(	O
This	O
is	O
the	O
"	O
decimation	O
in	O
time	O
"	O
case	O
;	O
one	O
can	O
also	O
perform	O
the	O
steps	O
in	O
reverse	O
,	O
known	O
as	O
"	O
decimation	O
in	O
frequency	O
"	O
,	O
where	O
the	O
butterflies	B-Application
come	O
first	O
and	O
are	O
post-multiplied	O
by	O
twiddle	O
factors	O
.	O
</s>
<s>
See	O
also	O
the	O
Cooley	B-Algorithm
–	I-Algorithm
Tukey	I-Algorithm
FFT	I-Algorithm
article	O
.	O
)	O
</s>
<s>
In	O
the	O
case	O
of	O
the	O
radix-2	O
Cooley	O
–	O
Tukey	O
algorithm	O
,	O
the	O
butterfly	B-Application
is	O
simply	O
a	O
DFT	O
of	O
size-2	O
that	O
takes	O
two	O
inputs	O
(	O
x0	O
,	O
x1	O
)	O
(	O
corresponding	O
outputs	O
of	O
the	O
two	O
sub-transforms	O
)	O
and	O
gives	O
two	O
outputs	O
(	O
y0	O
,	O
y1	O
)	O
by	O
the	O
formula	O
(	O
not	O
including	O
twiddle	O
factors	O
)	O
:	O
</s>
<s>
If	O
one	O
draws	O
the	O
data-flow	O
diagram	O
for	O
this	O
pair	O
of	O
operations	O
,	O
the	O
(	O
x0	O
,	O
x1	O
)	O
to	O
(	O
y0	O
,	O
y1	O
)	O
lines	O
cross	O
and	O
resemble	O
the	O
wings	O
of	O
a	O
butterfly	B-Application
,	O
hence	O
the	O
name	O
(	O
see	O
also	O
the	O
illustration	O
at	O
right	O
)	O
.	O
</s>
<s>
More	O
specifically	O
,	O
a	O
radix-2	O
decimation-in-time	O
FFT	O
algorithm	O
on	O
n	O
=	O
2	O
p	O
inputs	O
with	O
respect	O
to	O
a	O
primitive	O
n-th	O
root	O
of	O
unity	O
relies	O
on	O
O(nlog2n )	O
butterflies	B-Application
of	O
the	O
form	O
:	O
</s>
<s>
Whereas	O
the	O
corresponding	O
inverse	O
transform	O
can	O
mathematically	O
be	O
performed	O
by	O
replacing	O
ω	O
with	O
ω−1	O
(	O
and	O
possibly	O
multiplying	O
by	O
an	O
overall	O
scale	O
factor	O
,	O
depending	O
on	O
the	O
normalization	O
convention	O
)	O
,	O
one	O
may	O
also	O
directly	O
invert	O
the	O
butterflies	B-Application
:	O
</s>
<s>
The	O
butterfly	B-Application
can	O
also	O
be	O
used	O
to	O
improve	O
the	O
randomness	O
of	O
large	O
arrays	O
of	O
partially	O
random	O
numbers	O
,	O
by	O
bringing	O
every	O
32	O
or	O
64	O
bit	O
word	O
into	O
causal	O
contact	O
with	O
every	O
other	O
word	O
through	O
a	O
desired	O
hashing	O
algorithm	O
,	O
so	O
that	O
a	O
change	O
in	O
any	O
one	O
bit	O
has	O
the	O
possibility	O
of	O
changing	O
all	O
the	O
bits	O
in	O
the	O
large	O
array	O
.	O
</s>
