fft python
fft python
o Split the input into two halves: the samples at even indices and
those at odd indices.
o Recursively compute the FFT of each half (so you turn two
N/2-point problems into one N-point problem).
3. Butterfly combine
At each stage you have two lists of length N/2, call them
ini
CopyEdit
E = FFT(even_samples)
O = FFT(odd_samples)
Now you need to weave them back into one length-N list of frequency values.
You do that with a butterfly: for each index k from 0 to N/2–1,
mathematica
CopyEdit
where
cpp
CopyEdit
twiddle[k] = exp(2πi * k / N)
4. Why + and –?
o Sum ( + ) keeps the phase for the lower half of the spectrum.
5. Overall speedup
Because you halve the problem size at each step and do only N work
per stage, you go from O(N²) (naïve DFT) down to O(N log₂N).
FULL EXPLANATION:
1)
2)
3)
4)
5)
6)