Skip to main content

Fourier series of square wave and DFT

Short answer

Fourier series of ±A square wave: only odd harmonics, f(t) = (4A/π)(sin ω₀t + 1/3 sin 3ω₀t + …). 4-point DFT of {1,3,2,0}: X = {6, -1-j3, 0, -1+j3}. FFT reduces operations from N² to (N/2)log₂N, enabling fast real-time spectral analysis.

(a) Derive the Fourier series of a square wave of amplitude ±A\pm A and period TT, defined as +A+A for 0<t<T/20 < t < T/2 and −A-A for T/2<t<TT/2 < t < T.

(b) Four equally spaced samples of a signal are x={1,3,2,0}x = \{1, 3, 2, 0\}. Compute the 4-point DFT and state why the FFT is preferred for large NN.

(a) Fourier series of the square wave

A periodic signal of period TT and ω0=2π/T\omega_0 = 2\pi/T is written as

f(t)=a02+∑n=1∞(ancos⁡nω0t+bnsin⁡nω0t)f(t) = \frac{a_0}{2} + \sum_{n=1}^{\infty}\left(a_n\cos n\omega_0 t + b_n\sin n\omega_0 t\right)

with a0=2T∫0Tf dta_0 = \frac{2}{T}\int_0^T f\,dt, an=2T∫0Tfcos⁡nω0t dta_n = \frac{2}{T}\int_0^T f\cos n\omega_0 t\,dt, bn=2T∫0Tfsin⁡nω0t dtb_n = \frac{2}{T}\int_0^T f\sin n\omega_0 t\,dt.

  +A   +---------+         +---------+
       |         |         |         |
   0 --+---------+---------+---------+---> t
       |         |         |         |
  -A   |         +---------+         +----
       0        T/2        T       3T/2

The wave has zero mean over a period, so a0=0a_0 = 0. With the origin at the rising edge it is an odd function (about t=0t=0, over −T/2<t<T/2-T/2 < t < T/2), so all an=0a_n = 0.

bn=2T[∫0T/2Asin⁡nω0t dt−∫T/2TAsin⁡nω0t dt]b_n = \frac{2}{T}\left[\int_0^{T/2} A\sin n\omega_0 t\,dt - \int_{T/2}^{T} A\sin n\omega_0 t\,dt\right] ∫0T/2sin⁡nω0t dt=1−cos⁡nπnω0,∫T/2Tsin⁡nω0t dt=cos⁡nπ−1nω0\int_0^{T/2}\sin n\omega_0 t\,dt = \frac{1-\cos n\pi}{n\omega_0}, \qquad \int_{T/2}^{T}\sin n\omega_0 t\,dt = \frac{\cos n\pi - 1}{n\omega_0} bn=2AT⋅2(1−cos⁡nπ)nω0=2A(1−cos⁡nπ)nπb_n = \frac{2A}{T}\cdot\frac{2(1-\cos n\pi)}{n\omega_0} = \frac{2A(1-\cos n\pi)}{n\pi}

So bn=4A/(nπ)b_n = 4A/(n\pi) for odd nn and bn=0b_n = 0 for even nn. Therefore

f(t)=4Aπ[sin⁡ω0t+13sin⁡3ω0t+15sin⁡5ω0t+⋯ ]f(t) = \frac{4A}{\pi}\left[\sin\omega_0 t + \frac{1}{3}\sin 3\omega_0 t + \frac{1}{5}\sin 5\omega_0 t + \cdots\right]

Only odd harmonics exist, and their amplitudes fall as 1/n1/n.

(b) 4-point DFT

Xk=∑n=03xne−j2πkn/4,x={1,3,2,0}X_k = \sum_{n=0}^{3} x_n e^{-j2\pi kn/4}, \qquad x = \{1, 3, 2, 0\}

Using e−jπkn/2=1,−j,−1,je^{-j\pi k n/2} = 1, -j, -1, j for kn=0,1,2,3(mod4)kn = 0, 1, 2, 3 \pmod 4:

  • X0=1+3+2+0=6X_0 = 1+3+2+0 = 6
  • X1=1+3(−j)+2(−1)+0=−1−j3X_1 = 1 + 3(-j) + 2(-1) + 0 = -1 - j3
  • X2=1+3(−1)+2(1)+0=0X_2 = 1 + 3(-1) + 2(1) + 0 = 0
  • X3=1+3(j)+2(−1)+0=−1+j3X_3 = 1 + 3(j) + 2(-1) + 0 = -1 + j3
kXkX_kMagnitudePhase
0660
1−1−j3-1 - j33.16−108.4∘-108.4^\circ
200-
3−1+j3-1 + j33.16+108.4∘+108.4^\circ

Answer: X={6, −1−j3, 0, −1+j3}X = \{6,\ -1-j3,\ 0,\ -1+j3\}.

Why FFT

A direct DFT needs about N2N^2 complex multiplications. The FFT (Cooley-Tukey) repeatedly splits the sum into even and odd samples and needs only about (N/2)log⁡2N(N/2)\log_2 N. For N=1024N = 1024 this is about 5120 instead of about 1,000,000, so spectra can be obtained quickly, even in real time.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Instrumentation and Measurement chapter 2 questions →