ENع
→Fourier series
الدرس 21 · Fourier series and the Fourier transform

Fourier series: building waves from sines

لم يُترجم بعد؛ يُعرض باللغة الإنجليزية

15 دقيقة10 خطوات5 أسئلةIntermediate
عن هذا الدرس

Every periodic signal is a sum of sines at whole multiples of its frequency. Build a 1 kHz square wave on a bench of four oscillators: switch in 1, 3, 5 and 7 kHz with amplitudes 4/(πk) and watch the sum turn square. Then find those amplitudes with the analysis integral, read the spectrum, add 25 sines in Python with numpy and meet the Gibbs overshoot. Take the Circuits lessons on sinusoids and phasors first; the complex form uses the Signals lesson on complex exponentials, and the coefficient integral is the correlation idea from the lesson on correlation.

ستتعلّم

حدّد ما تشعر بأنك أتقنته. هذا التقييم الذاتي لا يؤثر في درجة الدرس.

شكل 21 · تفاعلي
01 / 10

The goal: a square wave

We want the output to be a square wave: +1 V for half a millisecond, then −1 V, over and over. It repeats every T0 = 1 ms, so its frequency is f0 = 1/T0 = 1 kHz. Can smooth sines make sharp corners?

target x(t), one period T0 = 1 ms:
  +1 V  for 0   <= t < 0.5 ms
  −1 V  for 0.5 <= t < 1   ms
then it repeats: x(t + T0) = x(t)

f0 = 1 / T0 = 1 / 0.001 s = 1000 Hz = 1 kHz

Fourier's claim: a periodic signal is a sum
of sines at f0, 2·f0, 3·f0 ... (harmonics)
جارٍ تحميل الرسم…
أو ← →
اقرأ الدرس خطوة بخطوة
  1. The goal: a square wave

    We want the output to be a square wave: +1 V for half a millisecond, then −1 V, over and over. It repeats every T0 = 1 ms, so its frequency is f0 = 1/T0 = 1 kHz. Can smooth sines make sharp corners?

    target x(t), one period T0 = 1 ms:
      +1 V  for 0   <= t < 0.5 ms
      −1 V  for 0.5 <= t < 1   ms
    then it repeats: x(t + T0) = x(t)
    
    f0 = 1 / T0 = 1 / 0.001 s = 1000 Hz = 1 kHz
    
    Fourier's claim: a periodic signal is a sum
    of sines at f0, 2·f0, 3·f0 ... (harmonics)
  2. One sine at f0

    Switch in a 1 kHz sine of amplitude 4/π ≈ 1.27 V. It has the same period as the square and rises and falls with it. Close, but round, and too high in the middle: 1.27 V at t = 0.25 ms.

    y1(t) = b1·sin(ω0·t)
      ω0 = 2π·f0   (radians per second)
      b1 = 4/π = 1.2732 V
    
    at t = 0.25 ms (a quarter period):
      sin(2π × 1 kHz × 0.25 ms) = sin(π/2) = 1
      y1 = 1.27 V   (target: 1.00 V)
    
    the arm on the dial turns once per period;
    its length is the amplitude b1
  3. Harmonics: whole multiples of f0

    Only sines that fit a whole number of times into T0 repeat every T0: f0, 2f0, 3f0 ... These are the harmonics. Watch the dials: harmonic k turns k times while the first turns once. Each arm's length is its amplitude.

    harmonic k:  frequency k·f0, period T0/k
      k = 1   1 kHz   turns 1 time per T0
      k = 3   3 kHz   turns 3 times
      k = 5   5 kHz   turns 5 times
      k = 7   7 kHz   turns 7 times
    
    every harmonic repeats after T0 too,
    so any sum of them has period T0
    
    arm lengths: 1.27 : 0.42 : 0.25 : 0.18 V
    (the dial is a phasor: see Circuits, "Phasors")
  4. Add the third harmonic

    Switch in 3 kHz with amplitude 4/(3π) ≈ 0.42 V. At t = 0.25 ms it is at its lowest, so it pulls the bump down: 1.27 − 0.42 = 0.85 V. The top flattens and the edges get steeper.

    y3(t) = b1·sin(ω0 t) + b3·sin(3ω0 t)
      b3 = 4/(3π) = 0.4244 V
    
    at t = 0.25 ms:
      sin(3 × π/2) = −1
      b1 term  +1.27
      b3 term  −0.42
      sum      0.85 V
    
    thin line in the plot: the 3 kHz sine alone
  5. Add 5 kHz and 7 kHz

    Add 5 kHz (0.25 V) and 7 kHz (0.18 V). With four sines the output at t = 0.25 ms is 0.92 V, and the wave already looks square. Each new harmonic corrects some of the error that is left.

    y7(t) = Σ b_k·sin(k·ω0·t),  k = 1, 3, 5, 7
      b5 = 4/(5π) = 0.25 V
      b7 = 4/(7π) = 0.18 V
    
    at t = 0.25 ms:
      4/π·(1 − 1/3 + 1/5 − 1/7) = 0.92 V
    
    highest point: 1.18 V at 62.5 µs,
    next to the jump
  6. Finding each amplitude

    Where does 0.42 V come from? Multiply the square by a 3 kHz sine, average over one period, double it: b3 = (2/T0)∫x(t)·sin(3ω0t)dt = 4/(3π). This is a correlation: how much of that sine the wave holds.

    analysis formula (one period):
      b_k = (2/T0) ∫ x(t)·sin(k·ω0·t) dt
      a_k = (2/T0) ∫ x(t)·cos(k·ω0·t) dt
    
    plot: x(t)·sin(3ω0 t). Its mean is 0.2122,
    so b3 = 2 × 0.2122 = 0.4244 V
    
    computed here by adding up 10000 thin slices;
    closed form: b_k = 4/(πk) for odd k
    
    all a_k = 0: x(t) is odd, so no cosines
  7. The spectrum: one line per sine

    For even k the integral is 0: the second half of the square is the first half flipped, which cancels them. Amplitude against frequency is the spectrum: lines at 1, 3, 5, 7 kHz of 1.27, 0.42, 0.25, 0.18 V, shrinking as 1/k.

    k   f (kHz)   b_k (V)
    1   1         1.27
    2   2         0.00
    3   3         0.42
    4   4         0.00
    5   5         0.25
    6   6         0.00
    7   7         0.18
    8   8         0.00
    9   9         0.14
    
    half-wave symmetry x(t + T0/2) = −x(t)
      -> only odd harmonics
    
    time plot and spectrum: two views
    of the same signal
  8. The same sum in Python

    In Python with numpy, t holds 1000 instants 1 µs apart: one period. The loop adds the odd harmonics k = 1, 3 ... 49, which is 25 sines, far more than the bench. np.sin works in radians, so w = 2π·1000.

    import numpy as np
    t = np.arange(1000) * 1e-6
    w = 2 * np.pi * 1000
    x = 0
    for k in range(1, 50, 2):
      x += 4/(np.pi*k)*np.sin(k*w*t)
    
    >>> print(round(x[250], 4))   # t = 0.25 ms
    1.0127
    >>> sq = np.where(t < 0.5e-3, 1.0, -1.0)
    >>> b3 = 2 * np.mean(sq * np.sin(3*w*t))
    >>> print(round(b3, 4))
    0.4244
    
    (Python 3 with numpy)
  9. Many sines: the Gibbs overshoot

    With 25 sines the edges are steep, yet each jump still overshoots to 1.18 V. More sines squeeze the ripple narrower but not lower: it stays near 9% of the 2 V jump. This is the Gibbs phenomenon.

    peak of the 25-sine sum: 1.1791 V
      at 10 µs after the jump
      overshoot 0.179 V = 9.0 % of the 2 V jump
    
    >>> print(round(x.max(), 4))
    1.1791
    
    limit for very many sines:
      0.0895 × jump (Wilbraham-Gibbs)
    the sum still converges at every point
    away from the jump
  10. Every periodic signal

    The square is one example. A periodic signal met in practice (a voice vowel, a violin note, a clock signal) is a sum of its harmonics with its own amplitudes and phases. Next, the Fourier transform does this for signals that never repeat.

    x(t) = a0 + Σ [ a_k·cos(k·ω0·t) + b_k·sin(k·ω0·t) ]
    
    a0       the average (0 V here)
    a_k, b_k  how much of each harmonic
    
    complex form (same content):
      x(t) = Σ c_k·e^(j·k·ω0·t)
      c_k = (1/T0) ∫ x(t)·e^(−j·k·ω0·t) dt
      square: c_k = −j·2/(πk), odd k
    
    works for signals that meet the
    Dirichlet conditions (all practical ones)

اختبار يتاح بعد الخطوة الأخيرة.