Fourier Series ऐनिमेशन का परिचय
(andreinc.net)- वृत्त और unit circle की rotational invariance से शुरू होकर sine·cosine, complex numbers, Euler formula, sinusoid और epicycles तक पहुंचने वाले प्रवाह को Fourier Series से दृश्य रूप में जोड़ा गया है
- unit circle का rotation, $\sin$ को y-coordinate और $\cos$ को x-coordinate के रूप में समझने देता है, और दोनों functions की period $2\pi$ तथा phase difference $\frac{\pi}{2}$ होती है
- complex plane में $e^{ix}=\cos(x)+i\sin(x)$ unit circle का rotation बन जाता है, और complex sinusoid cosine और sine को एक ही rotating object में बांधता है
- कई sinusoids को जोड़ने पर constructive और destructive interference होता है, और odd frequencies तथा घटती amplitude को मिलाने पर square wave जैसी discontinuous shape का भी क्रमशः बेहतर approximation मिलता है
- epicycles हर sinusoid को rotating circle और vector addition के रूप में दिखाते हैं, जहां radius amplitude $A$, rotational speed angular frequency $\omega$, और initial angle phase $\varphi$ के अनुरूप होता है
वृत्त, $\pi$, और radians से शुरू होने वाला rotation
- एक वृत्त को केंद्र $P(a,b)$ और त्रिज्या $r$ से परिभाषित किया जाता है, और बीजगणितीय रूप में इसे $(x-a)^2+(y-b)^2=r^2$ से व्यक्त किया जाता है
- जब केंद्र को origin पर और त्रिज्या को 1 रखा जाए, तो वह unit circle बन जाता है, और उसका समीकरण सरल होकर $x^2+y^2=1$ हो जाता है
- वृत्त पर एक बिंदु और उसके विपरीत परावर्तित बिंदु का संबंध rotation के बाद भी बना रहता है, और यही rotational invariance Fourier गणित की एक मुख्य सहज समझ बनती है
- $\pi$ वृत्त की परिधि और व्यास का अनुपात है, और हर वृत्त में इसका मान स्थिर $\pi \approx 3.14159...$ रहता है
- परिधि $P=2\pi r$ है
- क्षेत्रफल $A=\pi r^2$ है
- $\pi$ एक irrational number है, और साथ ही ऐसा transcendental number भी है जो rational coefficients वाले किसी non-zero polynomial का root नहीं है
- radian गणित और भौतिकी में कोण मापने की standard unit है, और degree को radian में बदलने के लिए कोण को $\pi$ से गुणा करके 180 से भाग दिया जाता है
- Fourier गणित में radians का उपयोग करने से trig functions को केवल कोण नहीं बल्कि real-valued functions की तरह लिया जा सकता है, जिससे waves और oscillations का calculus अधिक साफ हो जाता है
unit circle के आधार पर sine और cosine की व्याख्या
- $\sin$ और $\cos$ को unit circle पर घूमते हुए एक बिंदु के coordinates को track करने वाले functions की तरह देखा जा सकता है
- $\theta$ त्रिज्या और positive x-axis के बीच का कोण है
- $\sin$ बिंदु का vertical displacement, यानी y-coordinate है
- $\cos$ बिंदु का horizontal displacement, यानी x-coordinate है
- क्योंकि बिंदु फिर अपनी शुरुआती स्थिति में लौट आता है, $\sin$ और $\cos$ दोनों $2\pi$ period वाले periodic functions हैं
- $\cos$, $\sin$ जैसा ही waveform है, लेकिन $\frac{\pi}{2}$, यानी $90^\circ$ जितना shift हुआ रहता है
- $\sin(x+\frac{\pi}{2})=\cos(x)$
- तकनीकी रूप से, $\cos$ $\sin$ से $\frac{\pi}{2}$ आगे है
- इसी phase difference की वजह से दोनों functions quadrature संबंध बनाते हैं
- Fourier analysis में sine और cosine components को साथ इस्तेमाल करने से किसी भी periodic signal को उसके starting position, यानी phase, से स्वतंत्र रूप में व्यक्त किया जा सकता है
- function symmetry यानी parity के नज़रिए से $\cos$ even function है और $\sin$ odd function है
- $\cos(x)=\cos(-x)$
- $\sin(-x)=-\sin(x)$
complex numbers, $i$, और Euler formula
- complex plane में unit circle पर मौजूद हर बिंदु ऐसे complex number के अनुरूप होता है जिसका magnitude 1 हो
- किसी real angle $\theta$ के लिए $z=\cos(\theta)+i\sin(\theta)$ unit circle पर एक बिंदु है, और positive real axis से $\theta$ जितना rotation दर्शाता है
- किसी complex number को $i$ से गुणा करने पर complex plane में वह counterclockwise दिशा में $\frac{\pi}{2}$, यानी 90 degree, घूमता है
- magnitude $r=|a+bi|=\sqrt{a^2+b^2}$ बना रहता है
- केवल argument $\frac{\pi}{2}$ बढ़ता है
- उसी complex number को बार-बार $i$ से गुणा करने पर वह क्रम से quadrants में जाता है, और चार बार बाद फिर मूल स्थिति में लौट आता है
- natural constant $e \approx 2.71828$ एक irrational और transcendental number है, और इसे series तथा limits से परिभाषित किया जा सकता है
- $e=\sum_{n=0}^{\infty}\frac{1}{n!}$
- $e=\lim_{x\to\infty}(1+\frac{1}{x})^x$
- $e=\lim_{x\to0}(1+x)^{1/x}$
- natural exponential function, differentiation की eigenfunction है, क्योंकि derivative लेने पर वही function एक constant multiple के रूप में फिर मिलता है
- $\frac{d}{dx}e^{ax}=ae^{ax}$
- $f(x)=e^{ix}$ में हर differentiation पर $i$ से गुणा होता है, और चार बार differentiate करने पर फिर वही मूल function मिल जाता है
- $\frac{d}{dx}f(x)=ie^{ix}$
- $\frac{d^2}{dx^2}f(x)=-e^{ix}$
- $\frac{d^3}{dx^3}f(x)=-ie^{ix}$
- $\frac{d^4}{dx^4}f(x)=e^{ix}$
- यह pattern वैसा ही है जैसा complex number को बार-बार $i$ से गुणा करके घुमाना, और यहीं से $e^{ix}$ के complex plane पर वृत्त खींचने की सहज समझ बनती है
- Euler formula है $e^{ix}=\cos(x)+i\sin(x)$, और जब $x=\pi$ रखा जाए तो $e^{i\pi}+1=0$ मिलता है
- Euler formula की मदद से sine और cosine को exponential form में लिखा जा सकता है
- $\cos(x)=\frac{e^{ix}+e^{-ix}}{2}$
- $\sin(x)=\frac{e^{ix}-e^{-ix}}{2i}$
- वही parameter $x$, $t$, $\theta$ संदर्भ के अनुसार angle या time की तरह समझा जा सकता है, जबकि mathematical form एक ही रहती है
sinusoid और complex sinusoid
- sinusoid एक smooth और repetitive oscillation है, जिसे समय $t$ के function के रूप में $y(t)=A\sin(2\pi ft+\varphi)=A\sin(\omega t+\varphi)$ की तरह लिखा जाता है
- हर term waveform के shape और motion को तय करता है
- $A$ amplitude है, यानी center value 0 से maximum deviation
- $f$ सामान्य frequency है, जो प्रति second पूरे oscillations की संख्या बताती है, और Hz में मापी जाती है
- $\omega=2\pi f$ angular frequency है, जिसे cycles per second की जगह radians per second में मापा जाता है
- $\varphi$ phase offset या phase shift है, जो sinusoid को x-axis दिशा में बाएं-दाएं खिसकाता है
- $\sin$ और $\cos$ sinusoid के special cases हैं, और cosine wave, sine wave को $\frac{\pi}{2}$ radians बाईं ओर shift करने के बराबर है
- $A$, $\omega$, और $\varphi$ को बदलकर bass guitar की ध्वनि से लेकर घरों में इस्तेमाल होने वाली AC current तक, कई तरह के oscillations व्यक्त किए जा सकते हैं
- Euler formula में स्थिर angle $\theta$ को समय के साथ बदलने वाले $\omega t+\varphi$ से बदलने पर complex sinusoid मिलता है
- $s(t)=Ae^{i(\omega t+\varphi)}$
- $s(t)=A\cos(\omega t+\varphi)+iA\sin(\omega t+\varphi)$
- complex sinusoid दो waves को एक mathematical object में जोड़ देता है
- उसका real part cosine wave की तरह काम करता है
- imaginary part sine wave की तरह काम करता है
- दोनों components एक ही rotational angle $\theta=\omega t+\varphi$ पर निर्भर होते हैं, इसलिए synchronized रहते हैं
- complex sinusoid को Y-Z plane पर project करने से sine wave मिलती है, और X-Z plane पर project करने से cosine wave मिलती है
- एक rotating object की अलग-अलग orthogonal planes पर पड़ने वाली shadows ही परिचित real-valued sinusoids के रूप में दिखाई देती हैं
sinusoids का योग और interference
- कई sinusoids को जोड़ने पर हर बिंदु पर function values जुड़ती हैं, और peaks तथा troughs की alignment के अनुसार वे एक-दूसरे को बढ़ा या घटा सकती हैं
- यदि दो sinusoids के peaks और troughs एक-दूसरे के उलटे मेल खाएं, तो वे एक-दूसरे को घटाकर योग को 0 के करीब ला सकती हैं
- इस घटना को wave interference के रूप में समझा जा सकता है
- उदाहरण के लिए, दो sinusoids $y_1(x)=\frac{9}{10}\sin(7x+\frac{\pi}{2})$ और $y_2(x)=\frac{12}{10}\sin(3x-2)$ को जोड़ने पर $y(x)=y_1(x)+y_2(x)$ एक जटिल pattern बनाता है
- अलग-अलग frequencies और phase offsets वाले waveforms लगातार synchronization और desynchronization के बीच आते-जाते रहते हैं, और जैसे-जैसे अधिक sinusoids जुड़ते हैं, pattern और जटिल होता जाता है
sinusoids से square wave बनाना
- कुछ खास sinusoids को सावधानी से चुनने पर पूर्वानुमानित geometric patterns बनाए जा सकते हैं
- square wave को नीचे दिए गए infinite sum से बनाया जाता है
- $y(x)=\frac{4}{\pi}\sin(\omega x)+\frac{4}{3\pi}\sin(3\omega x)+...+\frac{4}{(2k-1)\pi}\sin((2k-1)\omega x)+...$
- इस representation में केवल odd frequencies जुड़ती हैं, और हर term की amplitude धीरे-धीरे घटती जाती है
- smooth continuous curves को जोड़ने पर peaks और troughs के interference से flat top वाली square wave बनती है
- sum में जितनी अधिक sinusoids शामिल की जाती हैं, approximation उतना ही sharp होता जाता है
- क्योंकि एक single sinusoid, वृत्त के चारों ओर घूमते हुए बिंदु के अनुरूप होती है, इसलिए sinusoids को जोड़ने की प्रक्रिया को rotating circles से जुड़े epicycles के रूप में देखा जा सकता है
- epicycles में दूसरे वृत्त का केंद्र पहले वृत्त की परिधि पर होता है, और तीसरे वृत्त का केंद्र दूसरे वृत्त की परिधि पर रखा जाता है
- हर epicycle किसी खास sinusoid के अनुरूप होता है, और इन्हें जोड़ने का काम क्रमिक vector addition के रूप में समझा जाता है
- उदाहरण के लिए, तीन sinusoids इस तरह जुड़ते हैं
- $y_1(x)=1.4\sin(x+1)$
- $y_2(x)=0.8\sin(2x)$
- $y_3(x)=0.5\sin(3x)$
- $y(x)=1.4\sin(x+1)+0.8\sin(2x)+0.5\sin(3x)$
- किसी भी समय कुल position vector को $\vec{u}=\vec{u_1}+\vec{u_2}+\vec{u_3}$ से व्यक्त किया जा सकता है
- सही sinusoids चुनने पर ये moving circles फूल जैसी मनचाही आकृतियों का approximation बना सकते हैं, और individual sinusoids को पहचानने के लिए Fourier Analysis की जरूरत होती है
Fourier Series का मूल रूप
- Fourier Series एक ऐसा mathematical process है जो period $P$ वाली periodic function को कई oscillating trig functions के infinite sum में विस्तारित करता है
- Pink Floyd के Dark Side of The Moon album cover की उपमा में periodic function $f(x)$ प्रकाश है, prism Fourier Mathematics है, और अलग हुए रंग simple sinusoid components के अनुरूप हैं
- इसका मूल formula इस प्रकार है
- $f(x)=A_0+\sum_{n=1}^{\infty}[A_n\cos(\frac{2\pi nx}{P})+B_n\sin(\frac{2\pi nx}{P})]$
- $A_0$, $A_n$, और $B_n$ Fourier coefficients हैं, जो बताते हैं कि मूल waveform को reconstruct करने के लिए किसी खास frequency की कितनी जरूरत है
- coefficients को integrals से निकाला जाता है
- $A_0=\frac{1}{P}\int_{-\frac{P}{2}}^{+\frac{P}{2}}f(x)dx$
- $A_n=\frac{2}{P}\int_{-\frac{P}{2}}^{+\frac{P}{2}}f(x)\cos(\frac{2\pi nx}{P})dx$
- $B_n=\frac{2}{P}\int_{-\frac{P}{2}}^{+\frac{P}{2}}f(x)\sin(\frac{2\pi nx}{P})dx$
- sine और cosine दृश्य रूप से सहज हैं, लेकिन algebraic manipulation में असुविधाजनक हो सकते हैं, इसलिए Euler formula की मदद से इन्हें exponential form में बदला जा सकता है
- exponential form की Fourier Series इस प्रकार है
- $f(x)=\sum_{n=-N}^{N}C_ne^{i2\pi\frac{n}{P}x}$
- exponential form में index $n$ negative values तक बढ़ता है, जो complex vectors के rotation direction को दर्शाने वाली negative frequency की अवधारणा लाता है
- संयुक्त coefficient formula इस प्रकार है
- $C_n=\frac{1}{P}\int_{-\frac{P}{2}}^{\frac{P}{2}}e^{-i2\pi\frac{n}{P}x}f(x)dx$
box function और square wave coefficients की गणना
- पहले इस्तेमाल किया गया square wave approximation इस प्रकार था
- $y(x)=\frac{4}{\pi}\sum_{k=1}^{\infty}\frac{\sin(2\pi(2k-1)fx)}{2k-1}$
- $\omega=2\pi f$ लेने पर $y(x)=\frac{4}{\pi}\sum_{k=1}^{\infty}\frac{\sin((2k-1)\omega x)}{2k-1}$
- square wave function को interval $[0,2L]$ पर Heaviside Step Function $H(x)$ की मदद से $f(x)=2[H(\frac{x}{L})-H(\frac{x}{L}-1)]-1$ लिखा जा सकता है
- $A_0$ interval $[0,2L]$ पर function का average है, और positive तथा negative areas के cancel हो जाने से इसका मान 0 होता है
- $A_n$ वे coefficients हैं जो $\cos$ terms को नियंत्रित करते हैं, और क्योंकि $f(x)$ odd function है तथा $\cos$ even function है, इसलिए उनका product odd function बनता है
- पूरे period पर integral लेने पर area cancel हो जाता है
- सभी $A_n$ coefficients 0 हो जाते हैं
- $B_n$ वे coefficients हैं जो $\sin$ terms को नियंत्रित करते हैं
- even $n$ पर लाल और हरे areas cancel हो जाते हैं, इसलिए integral value 0 होती है
- odd terms में areas जुड़ते हैं
- गणना का परिणाम $B_n=\frac{2}{n\pi}(1-(-1)^n)$ होता है
- चूंकि केवल odd $B_n$ terms बचती हैं, इसलिए square wave का रूप इस प्रकार बनता है
- $f(x)=\frac{4}{\pi}\sum_{n=1,3,5...}^{+\infty}(\frac{1}{n}\sin(\frac{\pi nx}{L}))$
- $n\rightarrow2k-1$ रखने पर $f(x)=\frac{4}{\pi}\sum_{k=1}^{+\infty}\frac{\sin(\frac{\pi(2k-1)x}{L})}{2k-1}$
- $L\rightarrow\frac{1}{2f}$, $2\pi f\rightarrow\omega$ रखने पर $f(x)=\frac{4}{\pi}\sum_{k=1}^{\infty}\frac{\sin((2k-1)\omega x)}{2k-1}$
- व्यवहार में infinite sum लेना संभव नहीं होता, इसलिए finite $n$ पर रुकने वाले partial sum $s(x)$ का उपयोग किया जाता है
- $s(x)=\frac{4}{\pi}\sum_{k=1}^{n}\frac{\sin((2k-1)\omega x)}{2k-1}\approx f(x)$
- $n$ बढ़ाने पर approximation की accuracy बेहतर होती जाती है, और approximation में बचा gap क्रमशः घटता जाता है
- शुरुआती पाँच terms तेजी से घटती amplitudes और बढ़ती frequencies वाले simple sinusoids से बने होते हैं
triangle wave और sawtooth wave के उदाहरण
- triangle wave का Fourier Series approximation इस प्रकार है
- $s(x)=\frac{8}{\pi^2}\sum_{k=1}^{N}\frac{(-1)^{k-1}}{(2k-1)^2}\sin((2k-1)x)$
- triangle wave smooth होती है और तेजी से converge करती है, और जब $n$ 6 के करीब पहुंचता है तो triangular shape स्पष्ट होने लगती है
- triangle wave expansion में $s_2(x)$, $s_4(x)$, $s_6(x)$ जैसी even-numbered terms negative होती हैं
- negative amplitude भौतिक रूप से सहज नहीं लगती, इसलिए इसे दो तरीकों से फिर लिखा जा सकता है
- $\sin(-x)=-\sin(x)$ का उपयोग करके frequency को negative बनाया जा सकता है
- amplitude को positive रखकर phase में $\pi$ जोड़ा जा सकता है
- व्यवहार में दूसरा तरीका अधिक practical है और बेहतर geometric control देता है
- $-\frac{8}{3^2\pi^2}\sin(3x)$ को $\frac{8}{3^2\pi^2}\sin(3x+\pi)$ की तरह लिखा जा सकता है
- reverse sawtooth wave function का रूप इस प्रकार है
- $s(x)=\frac{2}{\pi}\sum_{k=1}^{N}(-1)^k\frac{\sin(kx)}{k}$
Fourier Series को epicycles की तरह देखने की व्यवस्था
- स्थिर समीकरणों के बजाय अगर इसे physical motion की तरह देखा जाए, तो Fourier terms ऐसे कई rotating circles की तरह काम करते हैं जो rods पर end-to-end जुड़े होते हैं
- visual device में मनचाहे signal shape के रूप में sawtooth wave, triangle wave, square wave चुनी जा सकती हैं
- हर visual element, Fourier formula के variables से सीधे मेल खाता है
- हर circle की radius amplitude $A$ है
- हर circle की rotational speed angular frequency $\omega$ है
- $t=0$ पर circle के भीतर rod का initial angle phase offset $\varphi$ है
- जटिल, नुकीले और sharp waveforms को भी smooth rotating circles के combination में reverse-engineer किया जा सकता है
- यह animation, वृत्त, sinusoid, complex number, epicycle, और Fourier Series के बीच के संबंध को चरणबद्ध तरीके से दिखाने का काम करता है
1 टिप्पणियां
Hacker News की राय
discrete Fourier transform बस vector पर multiply किया जाने वाला एक orthogonal matrix है, और inverse FFT, Plancherel theorem, Parseval theorem भी इस बात से स्वाभाविक रूप से निकलते हैं कि वह matrix orthonormal है
यह तरीका शायद तभी काम करे जब linear algebra पहले से समझ में हो, लेकिन discrete नज़रिया पकड़ में आने के बाद continuous Fourier transform पर जाना भी आसान था
निजी तौर पर, circles और animations देखने की तुलना में equations को सीधे देखना मेरे लिए कहीं आसान था
[1] https://www.youtube.com/watch?v=spUNpyF58BY
[2] https://betterexplained.com/articles/an-interactive-guide-to...
[3] https://en.wikipedia.org/wiki/Discrete_Fourier_transform
बाकी लगभग वहीं से follow करता है। Fourier transform एक notation में f(x) को e^{-ikx} से multiply करके integrate करता है; integration एक बहुत बड़ा inner product है और e^{-ikx}, basis vector e^{ikx} के “transpose” जैसा है, इसलिए आखिरकार f_i को उस basis component के रूप में express कर रहे होते हैं
linear algebra समझने वाले ज़्यादातर लोग शायद advanced math जिस तरह सीखते हैं, उसी तरह—textbook या university lecture से—Fourier transform सीखेंगे। उस context में “vector पर multiply किया जाने वाला orthogonal matrix” जैसी explanation basic starting point होती है, लेकिन उसमें intuition की कमी लग सकती है, और YouTube videos उसी gap को भरने की कोशिश करते हैं
उदाहरण के लिए 3b1b video complex numbers क्यों useful हैं, यह भी धीरे-धीरे फिर से समझाता है, यानी target audience शुरू से ही अलग है
इसलिए math topics में मैं अब भी proofs खुद करके देखता हूं कि क्या मैं उन्हें अपने दम पर derive कर सकता हूं
काश सिर्फ खूबसूरत visualization देखकर concepts जादू की तरह दिमाग में बैठ जाते, लेकिन मेरे लिए यह एक तरह का intellectual dopamine जैसा लगता है
यह signals and systems field में “endofunctor category का monoid” कहने जैसा है
/छूट गया है, और असली link यह हैhttps://www.andreinc.net/2024/04/24/assets/js/2024-04-24-fro...
animation में शायद Processing इस्तेमाल किया गया है
https://github.com/nomemory/andreinc-site/tree/main/assets/j...
लेख लिखते समय मैं p5.js सीख रहा था, इसलिए शुरुआत काफी inefficient तरीके से हुई, और इस पर मुझे खास गर्व नहीं है
समय मिला तो लेख edit करके सही link डालूंगा
atypical depression से recover करने के लिए basic linear algebra पूरा Processing में visualize करने की योजना भी थी, लेकिन कुछ समय तक मैं computer पर programming कर ही नहीं पाया
कुछ दूसरे explanations complex numbers को अंत में जबरन फिट करते हैं
अगर इस topic में रुचि है, तो मेरे बनाए fractional Fourier transform visualization [1] और complex plane visualization [2] भी देखने लायक हैं
[1]: https://static.laszlokorte.de/frft-cube/
[2]: https://static.laszlokorte.de/complex-plane/
अगर किसी को explanatory material बनाना पसंद है, तो अच्छा होगा कि वह Laplace transform भी cover करे [1]
पहले मुझे पता था कि इसे electronic circuit analysis में कैसे इस्तेमाल करते हैं, लेकिन अब लगभग भूल गया हूं, इसलिए यह एक आलसी-सी request है
1: https://en.wikipedia.org/wiki/Laplace_transform
लेकिन यह लेख उस page से काफी आगे जाता है। आगे से लोगों के साथ share करने के लिए अच्छा रहेगा
Introduction to Graduate Algorithmscourse को follow करते हुए lecture content पूरा Python में implement करने के बाद ही मुझे FFT समझ आयासच में अच्छा course है:
https://edstem.org/us/courses/47529/lessons/80063/slides/440...
Ed के बारे में पहली बार सुना है और रुचि तो है, लेकिन “see how it works” section भी यह नहीं बताता कि यह सच में कैसे काम करता है। आजकल के trend की तरह लगता है कि पहले sign up करना होगा, यह अफसोसजनक है
Fourier series और Fourier transform पर videos और books इकट्ठा करके रखा गया एक useful site भी है:
https://howthefouriertransformworks.com/