4.10.26 · D2 · HinglishAdvanced Topics (Elite Level)

Visual walkthroughFourier analysis — DFT, FFT algorithm (Cooley-Tukey)

2,584 words12 min read↑ Read in English

4.10.26 · D2 · Maths › Advanced Topics (Elite Level) › Fourier analysis — DFT, FFT algorithm (Cooley-Tukey)


Step 0 — Ek word jo pehle define karna zaroori hai:

KYA HAI. Hum baar baar ek hi object par depend karenge, toh chaliye pehle usse bana lete hain. Origin par centre karke radius ka ek circle lo. Uspe equally spaced dots mark karo, point se shuru karke clockwise jaao. Start ke baad ka pehla dot kehlayega (padho "omega-sub-N").

CLOCKWISE KYUN? Kyunki DFT use karta hai — minus sign ek clockwise turn hai. Yeh minus kahaan se aata hai yeh hum baad mein dekhenge; abhi bas maan lo ki dots clockwise jaate hain.

PICTURE. Figure mein amber dot hai. dots walk karne par aap par pahunch jaate ho (multiply karna by matlab "ek aur step turn karo"). dots baad aap wapas aa jaate ho: . Yeh hain $N$-th roots of unity.

Figure — Fourier analysis — DFT, FFT algorithm (Cooley-Tukey)

Step 1 — points par ek "pure wave" ek dot hai jo fixed steps se spin karta hai

KYA HAI. Ek frequency fix karo (ek whole number). points ki ek list banao: dot se shuru karo aur har naye sample par dots clockwise jump karo. Sample dot par baithta hai. Woh points ek object mein collect karo aur usse bolao.

KYUN. Yeh list aur ka discrete cousin hai: iska horizontal shadow ek cosine trace karta hai, vertical shadow ek sine. Frequency = "ek sample mein kitne dots jump karte hain" = wave kitni tezi se wiggle karti hai. Yeh lists hamare building blocks hain — parent note ke basis vectors.

PICTURE. ke liye, ek sample per ek dot step karta hai (slow spin, slow wiggle); ek sample per do dots step karta hai (faster). Same circle, alag stride. Figure mein cyan curve () follow karo — ek gentle hump — versus amber curve () — same samples mein double wiggles.

Figure — Fourier analysis — DFT, FFT algorithm (Cooley-Tukey)

Step 2 — DFT poochta hai "mere data mein har wave kitni hai?"

KYA HAI. Data diya gaya hai, DFT coefficient measure karta hai ki wave data mein kitni strongly appear karti hai. Hum isse compute karte hain har sample ko wave ke against line karke aur add karke:

MULTIPLY-AND-ADD KYUN? Yeh ek orthogonal basis par projection hai. Kyunki waves orthogonal hain (parent Step 2, ek Geometric Series argument: ), data ko wave ke against match karna exactly wave ka share pick out karta hai aur har doosri wave ko zero cancel kar deta hai. Equations solve nahi karna — bas ek weighted sum.

PICTURE. Socho tuning forks hain, ek per frequency; batata hai fork kitna loud ring karta hai. Figure grid of weights stack karta hai — colour = har weight ka angle. Aise padho: top row () ek flat colour hai — har weight hai, toh bas plain sum hai. Ek row neeche jaao ( badhta hai) aur colours row ke across tezi se cycle karte hain: row poore colour-cycles sweep karta hai jab se tak jaata hai. Poore grid mein coloured cells hain — yeh literally woh multiplies hain jo FFT avoid karega.

Figure — Fourier analysis — DFT, FFT algorithm (Cooley-Tukey)

Step 3 — Sum split karo: even samples, odd samples

KYA HAI. Maano even hai. Samples ko index parity se sort karo: even-indexed wale aur odd-indexed wale . Ek bade sum ko do mein split karo:

PARITY SE KYUN SPLIT KARO? Kyunki — aur yahi saara magic hai — even part ek smaller DFT niklegaa, aur odd part bhi. Yeh ek divide-and-conquer move hai: same problem ke do half-size copies solve karo.

PICTURE. Figure data ko do choti rows mein comb karta hai: cyan bars "even comb" hain (), amber bars "odd comb" (). Notice karo ki har comb mein exactly teeth hain — do half-size problems.

Figure — Fourier analysis — DFT, FFT algorithm (Cooley-Tukey)

Step 4 — Odd part se ek twiddle factor bahar nikalo

KYA HAI. Odd sum mein, exponent hai . Kyunki , factor par depend nahi karta, toh woh sum ke bahar slide ho jaata hai:

BAHAR KYUN NIKALO? Kyunki ek baar woh chala jaata hai, dono remaining inner sums ka weight identical hota hai. Identical structure = dono ke liye ek hi sub-routine reuse kar sakte hain. Aakela bachaa hua twiddle factor kehlata hai — ek single rotation jo per output apply hoti hai.

PICTURE. Figure mein do cyan boxes even aur odd sums hain; ab woh same weight carry karte hain. Unke beech amber dot twiddle hai — woh ek rotation bahar nikali hui, odd box ke saamne baithee hai.

Figure — Fourier analysis — DFT, FFT algorithm (Cooley-Tukey)

Step 5 — Key identity:

KYA HAI. Shared weight dekho. Square group karo: . Ab compute karo:

YEH REDUCTION KYUN FINISH KARTA HAI? ek half-size grid ka twiddle hai. Toh har inner sum, literally ek -point DFT hai — even samples ka, odd samples ka. Humne ek size- problem ko do size- problems mein badal diya.

PICTURE. Figure mein faint white dots bade circle hain; amber dots half-size circle hain. Bade circle ke around double stride se step karna (squaring) exactly amber dots par land karta hai — squaring = har doosra dot skip karna = ek chhote circle par drop karna.

Figure — Fourier analysis — DFT, FFT algorithm (Cooley-Tukey)

Step 6 — Free second half: ek sign flip se do outputs milte hain

KYA HAI. Hamare paas ke liye hai. Lekin aur half-size DFTs hain, toh woh naturally sirf values produce karte hain — outputs kaise milenge? Poochho ki par kya hota hai. Do facts:

  • aur period ke saath repeat karte hain (length ka DFT wrap around ho jaata hai): , same ke liye.
  • Twiddle sign flip karta hai: , kyunki exactly half lap around ka dot hai .

YEH PAYOFF KYUN HAI. Yeh dono milao:

Dono outputs ek same multiply share karte hain — ek mein lagti hai, doosre mein . Do results, ek multiplication. Yeh hai butterfly.

PICTURE. Figure mein, do cyan inputs left side se enter karte hain; beech mein amber node single multiply hai; crossing lines usse upar le jaati hain (add → top output ) aur neeche (subtract → bottom output ). Woh crossing wings isliye butterfly kehlate hain.

Figure — Fourier analysis — DFT, FFT algorithm (Cooley-Tukey)

Step 7 — Edge & degenerate cases (reader ko kabhi stranded mat chhoddo)

KYA / KYUN / PICTURE, chaar corners jinhe aap zaroor hit karoge:

  • (base case). Ek single sample mein combine karne ko kuch nahi: . Recursion yahan ruk jaati hai — yeh "size-1 circle" hai, ek akela dot. Har FFT in par bottom out karta hai.
  • odd / power of 2 nahi. Even-odd split ko even chahiye; radix-2 ko chahiye. Doosre ke liye ya toh zero pad karo agle power of two tak, ya mixed-radix / Bluestein use karo. Picture: aap ek odd row ko do equal combs mein nahi kaat sakte.
  • (DC term). Har twiddle hai: , bas plain sum (average ). Frequency ki "wave" flat line hai — bilkul koi wiggle nahi.
  • (Nyquist). Fastest resolvable wave: yeh alternate karti hai. Yahan , toh . se aage, indices negative frequencies par alias ho jaate hain (parent ka last mistake). Dekho Sampling & Aliasing (Nyquist).

PICTURE. Figure do extreme waves overlay karta hai: cyan flat line DC wave hai (, koi wiggle nahi); amber zig-zag Nyquist wave hai (, fastest possible alternation). Har real frequency in dono ke beech rehti hai.

Figure — Fourier analysis — DFT, FFT algorithm (Cooley-Tukey)

Ek-picture summary

Upar sab kuch ke liye ek single diagram mein collapse ho jaata hai: do length-2 DFTs (har ek ek single butterfly) twiddles ki ek layer se feed hokar do output butterflies mein jaate hain. ko iske through trace karo aur aapko milega — brute-force sum ka same answer, fraction of the cost mein. Left se right padho: chaar inputs left pe enter karte hain; crossings ki pehli pair (cyan/amber) beech mein half-DFT values produce karti hai; crossings ki doosri pair twiddles apply karti hai aur add/subtract se right pe chaar outputs deti hai.

Figure — Fourier analysis — DFT, FFT algorithm (Cooley-Tukey)
Recall Feynman retelling (plain words, no symbols)

Socho ek wheel hai jisme equally spaced pegs hain. Ek "wave" ek marker hai jo har tick ek fixed number of pegs hop karta hai — fast wave ke liye zyada hop, slow wave ke liye thoda. DFT poochta hai, har possible hop-size ke liye, "kya yeh wave mera data mein chhup rahi hai?" — data ko us wave ke against rakhke aur add karke.

Har wave ke against har sample ke liye yeh karna ek giant grid of little multiplies hai — slow. FFT ka trick: apna data even-numbered aur odd-numbered samples mein split karo. Ek clean fact ki wajah se — bade wheel pe double-fast hop karna same hai jaise half the pegs wale wheel pe normally hop karna — har half same kind of problem ban jaata hai, but half the size. Woh do chhote problems solve karo, phir stitch karo: har pair ke liye odd answer ek baar spin karo (woh "twiddle"), phir add karo ek output ke liye aur subtract karo doosre ke liye. Do answers, ek spin. Woh paired add/subtract butterfly hai.

Halving karte raho — even/odd, even/odd — jab tak har piece ek single number na ho jo khud hi answer ho. Lagbhag layers of halving, har layer saare numbers ko ek baar touch karti hai. Isliye ban jaata hai, aur isliye aapka phone ek photo par Fourier transform kar sakta hai aapke blink khatam karne se pehle.

Recall Quick self-check

Woh single identity kaunsi hai jo har half-sum ko ek smaller DFT mein badal deti hai? ::: — twiddle ko square karna aapko half-size circle par drop kar deta hai. almost free kyun hai? ::: , toh shared product ka sirf sign flip hota hai. Ek butterfly ke do outputs kya hain? ::: aur . Recursion kahaan rukti hai? ::: par, jahan .